ITK  6.0.0
Insight Toolkit
itkAttributeKeepNObjectsLabelMapFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkAttributeKeepNObjectsLabelMapFilter_h
19#define itkAttributeKeepNObjectsLabelMapFilter_h
20
23
24namespace itk
25{
42template <typename TImage,
43 typename TAttributeAccessor =
44 typename Functor::AttributeLabelObjectAccessor<typename TImage::LabelObjectType>>
45class ITK_TEMPLATE_EXPORT AttributeKeepNObjectsLabelMapFilter : public InPlaceLabelMapFilter<TImage>
46{
47public:
48 ITK_DISALLOW_COPY_AND_MOVE(AttributeKeepNObjectsLabelMapFilter);
49
55
57 using ImageType = TImage;
60 using PixelType = typename ImageType::PixelType;
62 using LabelObjectType = typename ImageType::LabelObjectType;
63
64 using AttributeAccessorType = TAttributeAccessor;
65 using AttributeValueType = typename AttributeAccessorType::AttributeValueType;
66
68 static constexpr unsigned int ImageDimension = TImage::ImageDimension;
69
71 itkNewMacro(Self);
72
74 itkOverrideGetNameOfClassMacro(AttributeKeepNObjectsLabelMapFilter);
75
76#ifdef ITK_USE_CONCEPT_CHECKING
77 // Begin concept checking
78 /* itkConceptMacro(InputEqualityComparableCheck,
79 (Concept::EqualityComparable<InputImagePixelType>));
80 itkConceptMacro(IntConvertibleToInputCheck,
81 (Concept::Convertible<int, InputImagePixelType>));
82 itkConceptMacro(InputOStreamWritableCheck,
83 (Concept::OStreamWritable<InputImagePixelType>));*/
84 // End concept checking
85#endif
86
92 itkSetMacro(ReverseOrdering, bool);
93 itkGetConstReferenceMacro(ReverseOrdering, bool);
94 itkBooleanMacro(ReverseOrdering);
100 itkSetMacro(NumberOfObjects, SizeValueType);
101 itkGetConstReferenceMacro(NumberOfObjects, SizeValueType);
104protected:
107
108 void
109 GenerateData() override;
110
111 void
112 PrintSelf(std::ostream & os, Indent indent) const override;
113
115 {
116 public:
117 bool
118 operator()(const typename LabelObjectType::Pointer & a, const typename LabelObjectType::Pointer & b)
119 {
120 return m_Accessor(a) < m_Accessor(b);
121 }
123 : m_Accessor()
124 {}
125
126 private:
128 };
129
131 {
132 public:
133 bool
134 operator()(const typename LabelObjectType::Pointer & a, const typename LabelObjectType::Pointer & b)
135 {
136 return m_Accessor(a) > m_Accessor(b);
137 }
139 : m_Accessor()
140 {}
141
142 private:
144 };
145
146private:
147 bool m_ReverseOrdering{};
148 SizeValueType m_NumberOfObjects{};
149
150}; // end of class
151
152} // end namespace itk
153
154#ifndef ITK_MANUAL_INSTANTIATION
155# include "itkAttributeKeepNObjectsLabelMapFilter.hxx"
156#endif
157
158#endif
bool operator()(const typename LabelObjectType::Pointer &a, const typename LabelObjectType::Pointer &b)
bool operator()(const typename LabelObjectType::Pointer &a, const typename LabelObjectType::Pointer &b)
keep N objects according to their attribute value
typename AttributeAccessorType::AttributeValueType AttributeValueType
~AttributeKeepNObjectsLabelMapFilter() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
Base class for filters that takes an image as input and overwrites that image as the output.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86