ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkLabelStatisticsKeepNObjectsImageFilter.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 itkLabelStatisticsKeepNObjectsImageFilter_h
19 #define itkLabelStatisticsKeepNObjectsImageFilter_h
20 
25 
26 namespace itk
27 {
45 template< typename TInputImage, typename TFeatureImage >
46 class ITK_TEMPLATE_EXPORT LabelStatisticsKeepNObjectsImageFilter:
47  public ImageToImageFilter< TInputImage, TInputImage >
48 {
49 public:
50  ITK_DISALLOW_COPY_AND_ASSIGN(LabelStatisticsKeepNObjectsImageFilter);
51 
57 
59  using InputImageType = TInputImage;
60  using OutputImageType = TInputImage;
61  using InputImagePointer = typename InputImageType::Pointer;
62  using InputImageConstPointer = typename InputImageType::ConstPointer;
64  using InputImagePixelType = typename InputImageType::PixelType;
65  using OutputImagePointer = typename OutputImageType::Pointer;
66  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
68  using OutputImagePixelType = typename OutputImageType::PixelType;
69 
70  using FeatureImageType = TFeatureImage;
71  using FeatureImagePointer = typename FeatureImageType::Pointer;
72  using FeatureImageConstPointer = typename FeatureImageType::ConstPointer;
73  using FeatureImagePixelType = typename FeatureImageType::PixelType;
74 
76  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
77  static constexpr unsigned int OutputImageDimension = TInputImage::ImageDimension;
78  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
79 
87 
89  itkNewMacro(Self);
90 
94 
95 #ifdef ITK_USE_CONCEPT_CHECKING
96  // Begin concept checking
97  itkConceptMacro( InputEqualityComparableCheck,
99  itkConceptMacro( IntConvertibleToInputCheck,
101  itkConceptMacro( InputOStreamWritableCheck,
103  // End concept checking
104 #endif
105 
110  itkSetMacro(BackgroundValue, OutputImagePixelType);
111  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
113 
117  itkGetConstMacro(NumberOfObjects, SizeValueType);
118  itkSetMacro(NumberOfObjects, SizeValueType);
120 
126  itkGetConstMacro(ReverseOrdering, bool);
127  itkSetMacro(ReverseOrdering, bool);
128  itkBooleanMacro(ReverseOrdering);
130 
135  itkGetConstMacro(Attribute, AttributeType);
136  itkSetMacro(Attribute, AttributeType);
137  void SetAttribute(const std::string & s)
138  {
139  this->SetAttribute( LabelObjectType::GetAttributeFromName(s) );
140  }
142 
144  void SetFeatureImage(const TFeatureImage *input)
145  {
146  // Process object is not const-correct so the const casting is required.
147  this->SetNthInput( 1, const_cast< TFeatureImage * >( input ) );
148  }
149 
152  {
153  return static_cast< const FeatureImageType * >( this->ProcessObject::GetInput(1) );
154  }
155 
157  void SetInput1(const InputImageType *input)
158  {
159  this->SetInput(input);
160  }
161 
163  void SetInput2(const FeatureImageType *input)
164  {
165  this->SetFeatureImage(input);
166  }
167 
168 protected:
170  ~LabelStatisticsKeepNObjectsImageFilter() override = default;
171  void PrintSelf(std::ostream & os, Indent indent) const override;
172 
176  void GenerateInputRequestedRegion() override;
177 
179  void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) ) override;
180 
183  void GenerateData() override;
184 
185 private:
190 }; // end of class
191 } // end namespace itk
192 
193 #ifndef ITK_MANUAL_INSTANTIATION
194 #include "itkLabelStatisticsKeepNObjectsImageFilter.hxx"
195 #endif
196 
197 #endif
convert a labeled image to a label collection image
Light weight base class for most itk classes.
typename Superclass::AttributeType AttributeType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
A Label object to store the common attributes related to the statistics of the object.
keep N objects according to their statistics attributes
keep N objects according to their statistics attributes
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:70
The valuator class for the StatisticsLabelObject.
#define itkConceptMacro(name, concept)
Base class for all data objects in ITK.
Converts a LabelMap to a labeled image.