ITK  5.1.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 {
43 template <typename TImage,
44  typename TAttributeAccessor =
45  typename Functor::AttributeLabelObjectAccessor<typename TImage::LabelObjectType>>
46 class ITK_TEMPLATE_EXPORT AttributeKeepNObjectsLabelMapFilter : public InPlaceLabelMapFilter<TImage>
47 {
48 public:
49  ITK_DISALLOW_COPY_AND_ASSIGN(AttributeKeepNObjectsLabelMapFilter);
50 
56 
58  using ImageType = TImage;
59  using ImagePointer = typename ImageType::Pointer;
60  using ImageConstPointer = typename ImageType::ConstPointer;
61  using PixelType = typename ImageType::PixelType;
62  using IndexType = typename ImageType::IndexType;
63  using LabelObjectType = typename ImageType::LabelObjectType;
64 
65  using AttributeAccessorType = TAttributeAccessor;
66  using AttributeValueType = typename AttributeAccessorType::AttributeValueType;
67 
69  static constexpr unsigned int ImageDimension = TImage::ImageDimension;
70 
72  itkNewMacro(Self);
73 
76 
77 #ifdef ITK_USE_CONCEPT_CHECKING
78  // Begin concept checking
79  /* itkConceptMacro(InputEqualityComparableCheck,
80  (Concept::EqualityComparable<InputImagePixelType>));
81  itkConceptMacro(IntConvertibleToInputCheck,
82  (Concept::Convertible<int, InputImagePixelType>));
83  itkConceptMacro(InputOStreamWritableCheck,
84  (Concept::OStreamWritable<InputImagePixelType>));*/
85  // End concept checking
86 #endif
87 
93  itkSetMacro(ReverseOrdering, bool);
94  itkGetConstReferenceMacro(ReverseOrdering, bool);
95  itkBooleanMacro(ReverseOrdering);
97 
101  itkSetMacro(NumberOfObjects, SizeValueType);
102  itkGetConstReferenceMacro(NumberOfObjects, SizeValueType);
104 
105 protected:
107  ~AttributeKeepNObjectsLabelMapFilter() override = default;
108 
109  void
110  GenerateData() override;
111 
112  void
113  PrintSelf(std::ostream & os, Indent indent) const override;
114 
116  {
117  public:
118  bool
119  operator()(const typename LabelObjectType::Pointer & a, const typename LabelObjectType::Pointer & b)
120  {
121  return m_Accessor(a) < m_Accessor(b);
122  }
124  : m_Accessor()
125  {}
126 
127  private:
129  };
130 
132  {
133  public:
134  bool
135  operator()(const typename LabelObjectType::Pointer & a, const typename LabelObjectType::Pointer & b)
136  {
137  return m_Accessor(a) > m_Accessor(b);
138  }
140  : m_Accessor()
141  {}
142 
143  private:
145  };
146 
147 private:
150 
151 }; // end of class
152 
153 } // end namespace itk
154 
155 #ifndef ITK_MANUAL_INSTANTIATION
156 # include "itkAttributeKeepNObjectsLabelMapFilter.hxx"
157 #endif
158 
159 #endif
itk::AttributeKeepNObjectsLabelMapFilter::ImagePointer
typename ImageType::Pointer ImagePointer
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:59
itk::AttributeKeepNObjectsLabelMapFilter::AttributeAccessorType
TAttributeAccessor AttributeAccessorType
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:65
itk::AttributeKeepNObjectsLabelMapFilter
keep N objects according to their attribute value
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:46
itk::AttributeKeepNObjectsLabelMapFilter::Comparator
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:131
itk::AttributeKeepNObjectsLabelMapFilter::PixelType
typename ImageType::PixelType PixelType
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:61
itk::AttributeKeepNObjectsLabelMapFilter::ReverseComparator::ReverseComparator
ReverseComparator()
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:123
itk::AttributeKeepNObjectsLabelMapFilter::Comparator::operator()
bool operator()(const typename LabelObjectType::Pointer &a, const typename LabelObjectType::Pointer &b)
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:135
itk::InPlaceLabelMapFilter
Base class for filters that takes an image as input and overwrites that image as the output.
Definition: itkInPlaceLabelMapFilter.h:84
itk::AttributeKeepNObjectsLabelMapFilter::ReverseComparator
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:115
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:144
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::AttributeKeepNObjectsLabelMapFilter::AttributeValueType
typename AttributeAccessorType::AttributeValueType AttributeValueType
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:66
itk::AttributeKeepNObjectsLabelMapFilter::ImageType
TImage ImageType
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:58
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:119
itk::AttributeKeepNObjectsLabelMapFilter::IndexType
typename ImageType::IndexType IndexType
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:62
itkAttributeLabelObject.h
itk::AttributeKeepNObjectsLabelMapFilter::ReverseComparator::m_Accessor
AttributeAccessorType m_Accessor
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:128
itkInPlaceLabelMapFilter.h
itk::AttributeKeepNObjectsLabelMapFilter::m_ReverseOrdering
bool m_ReverseOrdering
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:148
itk::AttributeKeepNObjectsLabelMapFilter::Comparator::Comparator
Comparator()
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:139
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::AttributeKeepNObjectsLabelMapFilter::ImageConstPointer
typename ImageType::ConstPointer ImageConstPointer
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:60
itk::AttributeKeepNObjectsLabelMapFilter::LabelObjectType
typename ImageType::LabelObjectType LabelObjectType
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:63
itk::AttributeKeepNObjectsLabelMapFilter::m_NumberOfObjects
SizeValueType m_NumberOfObjects
Definition: itkAttributeKeepNObjectsLabelMapFilter.h:149
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83