ITK  4.9.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 > >
44  public InPlaceLabelMapFilter<TImage>
45 {
46 public:
52 
54  typedef TImage ImageType;
55  typedef typename ImageType::Pointer ImagePointer;
56  typedef typename ImageType::ConstPointer ImageConstPointer;
57  typedef typename ImageType::PixelType PixelType;
58  typedef typename ImageType::IndexType IndexType;
59  typedef typename ImageType::LabelObjectType LabelObjectType;
60 
61  typedef TAttributeAccessor AttributeAccessorType;
62  typedef typename AttributeAccessorType::AttributeValueType AttributeValueType;
63 
65  itkStaticConstMacro(ImageDimension, unsigned int,
66  TImage::ImageDimension);
67 
69  itkNewMacro(Self);
70 
74 
75 #ifdef ITK_USE_CONCEPT_CHECKING
76  // Begin concept checking
77 /* itkConceptMacro(InputEqualityComparableCheck,
78  (Concept::EqualityComparable<InputImagePixelType>));
79  itkConceptMacro(IntConvertibleToInputCheck,
80  (Concept::Convertible<int, InputImagePixelType>));
81  itkConceptMacro(InputOStreamWritableCheck,
82  (Concept::OStreamWritable<InputImagePixelType>));*/
83  // End concept checking
84 #endif
85 
91  itkSetMacro( ReverseOrdering, bool );
92  itkGetConstReferenceMacro( ReverseOrdering, bool );
93  itkBooleanMacro( ReverseOrdering );
95 
99  itkSetMacro( NumberOfObjects, SizeValueType );
100  itkGetConstReferenceMacro( NumberOfObjects, SizeValueType );
102 
103 protected:
106 
107  void GenerateData() ITK_OVERRIDE;
108 
109  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
110 
112  {
113  public:
114  bool operator()( const typename LabelObjectType::Pointer & a, const typename LabelObjectType::Pointer & b )
115  {
116  return m_Accessor( a ) < m_Accessor( b );
117  }
118  ReverseComparator() : m_Accessor() {}
119  private:
121  };
122 
124  {
125  public:
126  bool operator()( const typename LabelObjectType::Pointer & a, const typename LabelObjectType::Pointer & b )
127  {
128  return m_Accessor( a ) > m_Accessor( b );
129  }
131  private:
133  };
134 
135 private:
136  AttributeKeepNObjectsLabelMapFilter(const Self&) ITK_DELETE_FUNCTION;
137  void operator=(const Self&) ITK_DELETE_FUNCTION;
138 
141 
142 }; // end of class
143 
144 } // end namespace itk
145 
146 #ifndef ITK_MANUAL_INSTANTIATION
147 #include "itkAttributeKeepNObjectsLabelMapFilter.hxx"
148 #endif
149 
150 #endif
Light weight base class for most itk classes.
AttributeAccessorType::AttributeValueType AttributeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:143
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...
Control indentation during Print() invocation.
Definition: itkIndent.h:49
bool operator()(const typename LabelObjectType::Pointer &a, const typename LabelObjectType::Pointer &b)
void PrintSelf(std::ostream &os, Indent indent) const override
keep N objects according to their attribute value