ITK  5.2.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  * http://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 
24 namespace itk
25 {
42 template <typename TImage,
43  typename TAttributeAccessor =
44  typename Functor::AttributeLabelObjectAccessor<typename TImage::LabelObjectType>>
45 class ITK_TEMPLATE_EXPORT AttributeKeepNObjectsLabelMapFilter : public InPlaceLabelMapFilter<TImage>
46 {
47 public:
48  ITK_DISALLOW_COPY_AND_MOVE(AttributeKeepNObjectsLabelMapFilter);
49 
55 
57  using ImageType = TImage;
58  using ImagePointer = typename ImageType::Pointer;
59  using ImageConstPointer = typename ImageType::ConstPointer;
60  using PixelType = typename ImageType::PixelType;
61  using IndexType = typename ImageType::IndexType;
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 
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);
96 
100  itkSetMacro(NumberOfObjects, SizeValueType);
101  itkGetConstReferenceMacro(NumberOfObjects, SizeValueType);
103 
104 protected:
106  ~AttributeKeepNObjectsLabelMapFilter() override = default;
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 
146 private:
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
itk::AttributeKeepNObjectsLabelMapFilter::ImagePointer
typename ImageType::Pointer ImagePointer
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:58
itk::AttributeKeepNObjectsLabelMapFilter::AttributeAccessorType
TAttributeAccessor AttributeAccessorType
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:64
itk::AttributeKeepNObjectsLabelMapFilter
keep N objects according to their attribute value
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:45
itk::AttributeKeepNObjectsLabelMapFilter::Comparator
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:130
itk::AttributeKeepNObjectsLabelMapFilter::PixelType
typename ImageType::PixelType PixelType
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:60
itk::AttributeKeepNObjectsLabelMapFilter::ReverseComparator::ReverseComparator
ReverseComparator()
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:122
itk::AttributeKeepNObjectsLabelMapFilter::Comparator::operator()
bool operator()(const typename LabelObjectType::Pointer &a, const typename LabelObjectType::Pointer &b)
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:134
itk::InPlaceLabelMapFilter
Base class for filters that takes an image as input and overwrites that image as the output.
Definition: itkInPlaceLabelMapFilter.h:83
itk::AttributeKeepNObjectsLabelMapFilter::ReverseComparator
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:114
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::AttributeKeepNObjectsLabelMapFilter::Comparator::m_Accessor
AttributeAccessorType m_Accessor
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:143
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::AttributeKeepNObjectsLabelMapFilter::AttributeValueType
typename AttributeAccessorType::AttributeValueType AttributeValueType
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:65
itk::AttributeKeepNObjectsLabelMapFilter::ImageType
TImage ImageType
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:57
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::AttributeKeepNObjectsLabelMapFilter::ReverseComparator::operator()
bool operator()(const typename LabelObjectType::Pointer &a, const typename LabelObjectType::Pointer &b)
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:118
itk::AttributeKeepNObjectsLabelMapFilter::IndexType
typename ImageType::IndexType IndexType
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:61
itkAttributeLabelObject.h
itk::AttributeKeepNObjectsLabelMapFilter::ReverseComparator::m_Accessor
AttributeAccessorType m_Accessor
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:127
itkInPlaceLabelMapFilter.h
itk::AttributeKeepNObjectsLabelMapFilter::m_ReverseOrdering
bool m_ReverseOrdering
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:147
itk::AttributeKeepNObjectsLabelMapFilter::Comparator::Comparator
Comparator()
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:138
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::AttributeKeepNObjectsLabelMapFilter::ImageConstPointer
typename ImageType::ConstPointer ImageConstPointer
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:59
itk::AttributeKeepNObjectsLabelMapFilter::LabelObjectType
typename ImageType::LabelObjectType LabelObjectType
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:62
itk::AttributeKeepNObjectsLabelMapFilter::m_NumberOfObjects
SizeValueType m_NumberOfObjects
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:148
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83