ITK  5.1.0
Insight Toolkit
itkBinaryStatisticsKeepNObjectsImageFilter.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 itkBinaryStatisticsKeepNObjectsImageFilter_h
19 #define itkBinaryStatisticsKeepNObjectsImageFilter_h
20 
25 
26 namespace itk
27 {
46 template <typename TInputImage, typename TFeatureImage>
47 class ITK_TEMPLATE_EXPORT BinaryStatisticsKeepNObjectsImageFilter : public ImageToImageFilter<TInputImage, TInputImage>
48 {
49 public:
50  ITK_DISALLOW_COPY_AND_ASSIGN(BinaryStatisticsKeepNObjectsImageFilter);
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 
81 
89 
91  itkNewMacro(Self);
92 
95 
102  itkSetMacro(FullyConnected, bool);
103  itkGetConstReferenceMacro(FullyConnected, bool);
104  itkBooleanMacro(FullyConnected);
106 
107 #ifdef ITK_USE_CONCEPT_CHECKING
108  // Begin concept checking
109  itkConceptMacro(InputEqualityComparableCheck, (Concept::EqualityComparable<InputImagePixelType>));
112  // End concept checking
113 #endif
114 
119  itkSetMacro(BackgroundValue, OutputImagePixelType);
120  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
122 
127  itkSetMacro(ForegroundValue, OutputImagePixelType);
128  itkGetConstMacro(ForegroundValue, OutputImagePixelType);
130 
134  itkGetConstMacro(NumberOfObjects, SizeValueType);
135  itkSetMacro(NumberOfObjects, SizeValueType);
137 
143  itkGetConstMacro(ReverseOrdering, bool);
144  itkSetMacro(ReverseOrdering, bool);
145  itkBooleanMacro(ReverseOrdering);
147 
152  itkGetConstMacro(Attribute, AttributeType);
153  itkSetMacro(Attribute, AttributeType);
154  void
155  SetAttribute(const std::string & s)
156  {
157  this->SetAttribute(LabelObjectType::GetAttributeFromName(s));
158  }
160 
162  void
163  SetFeatureImage(const TFeatureImage * input)
164  {
165  // Process object is not const-correct so the const casting is required.
166  this->SetNthInput(1, const_cast<TFeatureImage *>(input));
167  }
168 
170  const FeatureImageType *
172  {
173  return static_cast<const FeatureImageType *>(this->ProcessObject::GetInput(1));
174  }
175 
177  void
178  SetInput1(const InputImageType * input)
179  {
180  this->SetInput(input);
181  }
182 
184  void
186  {
187  this->SetFeatureImage(input);
188  }
189 
190 protected:
192  ~BinaryStatisticsKeepNObjectsImageFilter() override = default;
193  void
194  PrintSelf(std::ostream & os, Indent indent) const override;
195 
199  void
200  GenerateInputRequestedRegion() override;
201 
203  void
204  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
205 
208  void
209  GenerateData() override;
210 
211 private:
212  bool m_FullyConnected{ false };
215  SizeValueType m_NumberOfObjects{ 0 };
216  bool m_ReverseOrdering{ false };
218 }; // end of class
219 } // end namespace itk
220 
221 #ifndef ITK_MANUAL_INSTANTIATION
222 # include "itkBinaryStatisticsKeepNObjectsImageFilter.hxx"
223 #endif
224 
225 #endif
itk::BinaryStatisticsKeepNObjectsImageFilter::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:66
itkStatisticsKeepNObjectsLabelMapFilter.h
itk::BinaryStatisticsKeepNObjectsImageFilter
keep N objects according to their statistics attributes
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:47
itk::BinaryStatisticsKeepNObjectsImageFilter::FeatureImageConstPointer
typename FeatureImageType::ConstPointer FeatureImageConstPointer
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:72
itk::Concept::OStreamWritable
Definition: itkConceptChecking.h:634
itk::StatisticsLabelMapFilter
The valuator class for the StatisticsLabelObject.
Definition: itkStatisticsLabelMapFilter.h:42
itk::BinaryStatisticsKeepNObjectsImageFilter::m_ForegroundValue
OutputImagePixelType m_ForegroundValue
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:214
itkStatisticsLabelMapFilter.h
itk::BinaryStatisticsKeepNObjectsImageFilter::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:68
itk::BinaryStatisticsKeepNObjectsImageFilter::m_Attribute
AttributeType m_Attribute
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:217
itk::LabelMapToBinaryImageFilter
Convert a LabelMap to a binary image.
Definition: itkLabelMapToBinaryImageFilter.h:46
itk::BinaryStatisticsKeepNObjectsImageFilter::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:67
itk::StatisticsLabelObject
A Label object to store the common attributes related to the statistics of the object.
Definition: itkStatisticsLabelObject.h:42
itk::BinaryStatisticsKeepNObjectsImageFilter::SetAttribute
void SetAttribute(const std::string &s)
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:155
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:47
itk::BinaryStatisticsKeepNObjectsImageFilter::SetFeatureImage
void SetFeatureImage(const TFeatureImage *input)
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:163
itk::BinaryStatisticsKeepNObjectsImageFilter::FeatureImagePixelType
typename FeatureImageType::PixelType FeatureImagePixelType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:73
itk::BinaryImageToLabelMapFilter
Label the connected components in a binary image and produce a collection of label objects.
Definition: itkBinaryImageToLabelMapFilter.h:56
itk::LabelMap
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:71
itk::BinaryStatisticsKeepNObjectsImageFilter::GetFeatureImage
const FeatureImageType * GetFeatureImage()
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:171
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:59
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::BinaryStatisticsKeepNObjectsImageFilter::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:65
itkLabelMapToBinaryImageFilter.h
itkBinaryImageToLabelMapFilter.h
itk::BinaryStatisticsKeepNObjectsImageFilter::AttributeType
typename LabelObjectType::AttributeType AttributeType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:86
itk::BinaryStatisticsKeepNObjectsImageFilter::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:64
itk::BinaryStatisticsKeepNObjectsImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:61
itk::BinaryStatisticsKeepNObjectsImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:63
itk::BinaryStatisticsKeepNObjectsImageFilter::OutputImageType
TInputImage OutputImageType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:60
itk::BinaryStatisticsKeepNObjectsImageFilter::InputImageType
TInputImage InputImageType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:59
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:64
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::BinaryStatisticsKeepNObjectsImageFilter::InputImageConstPointer
typename InputImageType::ConstPointer InputImageConstPointer
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:62
itk::BinaryStatisticsKeepNObjectsImageFilter::SetInput1
void SetInput1(const InputImageType *input)
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:178
itk::BinaryStatisticsKeepNObjectsImageFilter::m_BackgroundValue
OutputImagePixelType m_BackgroundValue
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:213
itk::Concept::Convertible
Definition: itkConceptChecking.h:214
itk::BinaryStatisticsKeepNObjectsImageFilter::SetInput2
void SetInput2(const FeatureImageType *input)
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:185
itk::StatisticsLabelObject::AttributeType
typename Superclass::AttributeType AttributeType
Definition: itkStatisticsLabelObject.h:81
itk::BinaryStatisticsKeepNObjectsImageFilter::FeatureImagePointer
typename FeatureImageType::Pointer FeatureImagePointer
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:71
itk::BinaryStatisticsKeepNObjectsImageFilter::FeatureImageType
TFeatureImage FeatureImageType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:70
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itk::Concept::EqualityComparable
Definition: itkConceptChecking.h:304
itk::BinaryStatisticsKeepNObjectsImageFilter::LabelType
SizeValueType LabelType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:80
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293