ITK  6.0.0
Insight Toolkit
itkLabelStatisticsKeepNObjectsImageFilter.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  * https://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 : public ImageToImageFilter<TInputImage, TInputImage>
47 {
48 public:
49  ITK_DISALLOW_COPY_AND_MOVE(LabelStatisticsKeepNObjectsImageFilter);
50 
56 
58  using InputImageType = TInputImage;
59  using OutputImageType = TInputImage;
63  using InputImagePixelType = typename InputImageType::PixelType;
67  using OutputImagePixelType = typename OutputImageType::PixelType;
68 
69  using FeatureImageType = TFeatureImage;
72  using FeatureImagePixelType = typename FeatureImageType::PixelType;
73 
75  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
76  static constexpr unsigned int OutputImageDimension = TInputImage::ImageDimension;
77  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
78 
86 
88  itkNewMacro(Self);
89 
91  itkOverrideGetNameOfClassMacro(LabelStatisticsKeepNObjectsImageFilter);
92 
93 #ifdef ITK_USE_CONCEPT_CHECKING
94  // Begin concept checking
98  // End concept checking
99 #endif
100 
105  itkSetMacro(BackgroundValue, OutputImagePixelType);
106  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
112  itkGetConstMacro(NumberOfObjects, SizeValueType);
113  itkSetMacro(NumberOfObjects, SizeValueType);
121  itkGetConstMacro(ReverseOrdering, bool);
122  itkSetMacro(ReverseOrdering, bool);
123  itkBooleanMacro(ReverseOrdering);
130  itkGetConstMacro(Attribute, AttributeType);
131  itkSetMacro(Attribute, AttributeType);
132  void
133  SetAttribute(const std::string & s)
134  {
135  this->SetAttribute(LabelObjectType::GetAttributeFromName(s));
136  }
140  void
141  SetFeatureImage(const TFeatureImage * input)
142  {
143  // Process object is not const-correct so the const casting is required.
144  this->SetNthInput(1, const_cast<TFeatureImage *>(input));
145  }
146 
148  const FeatureImageType *
150  {
151  return static_cast<const FeatureImageType *>(this->ProcessObject::GetInput(1));
152  }
153 
155  void
156  SetInput1(const InputImageType * input)
157  {
158  this->SetInput(input);
159  }
160 
162  void
164  {
165  this->SetFeatureImage(input);
166  }
167 
168 protected:
170  ~LabelStatisticsKeepNObjectsImageFilter() override = default;
171  void
172  PrintSelf(std::ostream & os, Indent indent) const override;
173 
177  void
178  GenerateInputRequestedRegion() override;
179 
181  void
182  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
183 
186  void
187  GenerateData() override;
188 
189 private:
190  OutputImagePixelType m_BackgroundValue{};
191  SizeValueType m_NumberOfObjects{};
192  bool m_ReverseOrdering{};
193  AttributeType m_Attribute{};
194 }; // end of class
195 } // end namespace itk
196 
197 #ifndef ITK_MANUAL_INSTANTIATION
198 # include "itkLabelStatisticsKeepNObjectsImageFilter.hxx"
199 #endif
200 
201 #endif
itkLabelImageToLabelMapFilter.h
itk::LabelObject::AttributeType
unsigned int AttributeType
Definition: itkLabelObject.h:92
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itkStatisticsKeepNObjectsLabelMapFilter.h
itk::LabelStatisticsKeepNObjectsImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:62
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::Concept::OStreamWritable
Definition: itkConceptChecking.h:638
itk::LabelStatisticsKeepNObjectsImageFilter::FeatureImagePixelType
typename FeatureImageType::PixelType FeatureImagePixelType
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:72
itk::StatisticsLabelMapFilter
The valuator class for the StatisticsLabelObject.
Definition: itkStatisticsLabelMapFilter.h:41
itk::LabelStatisticsKeepNObjectsImageFilter::InputImageConstPointer
typename InputImageType::ConstPointer InputImageConstPointer
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:61
itkStatisticsLabelMapFilter.h
itk::LabelStatisticsKeepNObjectsImageFilter::FeatureImageConstPointer
typename FeatureImageType::ConstPointer FeatureImageConstPointer
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:71
itk::LabelImageToLabelMapFilter
convert a labeled image to a label collection image
Definition: itkLabelImageToLabelMapFilter.h:49
itk::StatisticsLabelObject
A Label object to store the common attributes related to the statistics of the object.
Definition: itkStatisticsLabelObject.h:41
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::StatisticsKeepNObjectsLabelMapFilter
keep N objects according to their statistics attributes
Definition: itkStatisticsKeepNObjectsLabelMapFilter.h:45
itk::LabelStatisticsKeepNObjectsImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:60
itk::LabelStatisticsKeepNObjectsImageFilter::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:65
itk::LabelStatisticsKeepNObjectsImageFilter::SetInput2
void SetInput2(const FeatureImageType *input)
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:163
itk::LabelMap
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:70
itk::LabelStatisticsKeepNObjectsImageFilter::OutputImageType
TInputImage OutputImageType
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:59
itk::LabelStatisticsKeepNObjectsImageFilter
keep N objects according to their statistics attributes
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:46
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::LabelStatisticsKeepNObjectsImageFilter::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:67
itk::LabelStatisticsKeepNObjectsImageFilter::InputImageType
TInputImage InputImageType
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:58
itk::LabelStatisticsKeepNObjectsImageFilter::FeatureImageType
TFeatureImage FeatureImageType
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:69
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Concept::Convertible
Definition: itkConceptChecking.h:216
itk::LabelMapToLabelImageFilter
Converts a LabelMap to a labeled image.
Definition: itkLabelMapToLabelImageFilter.h:46
itk::LabelStatisticsKeepNObjectsImageFilter::SetAttribute
void SetAttribute(const std::string &s)
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:133
itk::LabelStatisticsKeepNObjectsImageFilter::SetFeatureImage
void SetFeatureImage(const TFeatureImage *input)
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:141
itk::LabelStatisticsKeepNObjectsImageFilter::AttributeType
typename LabelObjectType::AttributeType AttributeType
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:83
itkLabelMapToLabelImageFilter.h
itk::LabelStatisticsKeepNObjectsImageFilter::FeatureImagePointer
typename FeatureImageType::Pointer FeatureImagePointer
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:70
itk::LabelStatisticsKeepNObjectsImageFilter::SetInput1
void SetInput1(const InputImageType *input)
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:156
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itk::Concept::EqualityComparable
Definition: itkConceptChecking.h:306
itk::LabelStatisticsKeepNObjectsImageFilter::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:64
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::LabelStatisticsKeepNObjectsImageFilter::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:66
itk::LabelStatisticsKeepNObjectsImageFilter::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:63
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293
itk::LabelStatisticsKeepNObjectsImageFilter::GetFeatureImage
const FeatureImageType * GetFeatureImage()
Definition: itkLabelStatisticsKeepNObjectsImageFilter.h:149