ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkAttributeKeepNObjectsLabelMapFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 {
41 template<typename TImage, typename TAttributeAccessor=
42  typename Functor::AttributeLabelObjectAccessor< typename TImage::LabelObjectType > >
43 class ITK_TEMPLATE_EXPORT AttributeKeepNObjectsLabelMapFilter :
44  public InPlaceLabelMapFilter<TImage>
45 {
46 public:
47  ITK_DISALLOW_COPY_AND_ASSIGN(AttributeKeepNObjectsLabelMapFilter);
48 
54 
56  using ImageType = TImage;
57  using ImagePointer = typename ImageType::Pointer;
58  using ImageConstPointer = typename ImageType::ConstPointer;
59  using PixelType = typename ImageType::PixelType;
60  using IndexType = typename ImageType::IndexType;
61  using LabelObjectType = typename ImageType::LabelObjectType;
62 
63  using AttributeAccessorType = TAttributeAccessor;
64  using AttributeValueType = typename AttributeAccessorType::AttributeValueType;
65 
67  static constexpr unsigned int ImageDimension = TImage::ImageDimension;
68 
70  itkNewMacro(Self);
71 
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 GenerateData() override;
109 
110  void PrintSelf(std::ostream& os, Indent indent) const override;
111 
113  {
114  public:
115  bool operator()( const typename LabelObjectType::Pointer & a, const typename LabelObjectType::Pointer & b )
116  {
117  return m_Accessor( a ) < m_Accessor( b );
118  }
119  ReverseComparator() : m_Accessor() {}
120  private:
122  };
123 
125  {
126  public:
127  bool operator()( const typename LabelObjectType::Pointer & a, const typename LabelObjectType::Pointer & b )
128  {
129  return m_Accessor( a ) > m_Accessor( b );
130  }
131  Comparator(): m_Accessor () {}
132  private:
134  };
135 
136 private:
139 
140 }; // end of class
141 
142 } // end namespace itk
143 
144 #ifndef ITK_MANUAL_INSTANTIATION
145 #include "itkAttributeKeepNObjectsLabelMapFilter.hxx"
146 #endif
147 
148 #endif
Light weight base class for most itk classes.
unsigned long SizeValueType
Definition: itkIntTypes.h:83
bool operator()(const typename LabelObjectType::Pointer &a, const typename LabelObjectType::Pointer &b)
Base class for filters that takes an image as input and overwrites that image as the output...
typename AttributeAccessorType::AttributeValueType AttributeValueType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
bool operator()(const typename LabelObjectType::Pointer &a, const typename LabelObjectType::Pointer &b)
keep N objects according to their attribute value