ITK  5.1.0
Insight Toolkit
itkBinaryStatisticsKeepNObjectsImageFilter.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 itkBinaryStatisticsKeepNObjectsImageFilter_h
19 #define itkBinaryStatisticsKeepNObjectsImageFilter_h
20 
25 
26 namespace itk
27 {
45 template <typename TInputImage, typename TFeatureImage>
46 class ITK_TEMPLATE_EXPORT BinaryStatisticsKeepNObjectsImageFilter : public ImageToImageFilter<TInputImage, TInputImage>
47 {
48 public:
49  ITK_DISALLOW_COPY_AND_ASSIGN(BinaryStatisticsKeepNObjectsImageFilter);
50 
56 
58  using InputImageType = TInputImage;
59  using OutputImageType = TInputImage;
60  using InputImagePointer = typename InputImageType::Pointer;
61  using InputImageConstPointer = typename InputImageType::ConstPointer;
63  using InputImagePixelType = typename InputImageType::PixelType;
64  using OutputImagePointer = typename OutputImageType::Pointer;
65  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
67  using OutputImagePixelType = typename OutputImageType::PixelType;
68 
69  using FeatureImageType = TFeatureImage;
70  using FeatureImagePointer = typename FeatureImageType::Pointer;
71  using FeatureImageConstPointer = typename FeatureImageType::ConstPointer;
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 
80 
88 
90  itkNewMacro(Self);
91 
94 
101  itkSetMacro(FullyConnected, bool);
102  itkGetConstReferenceMacro(FullyConnected, bool);
103  itkBooleanMacro(FullyConnected);
105 
106 #ifdef ITK_USE_CONCEPT_CHECKING
107  // Begin concept checking
108  itkConceptMacro(InputEqualityComparableCheck, (Concept::EqualityComparable<InputImagePixelType>));
111  // End concept checking
112 #endif
113 
118  itkSetMacro(BackgroundValue, OutputImagePixelType);
119  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
121 
126  itkSetMacro(ForegroundValue, OutputImagePixelType);
127  itkGetConstMacro(ForegroundValue, OutputImagePixelType);
129 
133  itkGetConstMacro(NumberOfObjects, SizeValueType);
134  itkSetMacro(NumberOfObjects, SizeValueType);
136 
142  itkGetConstMacro(ReverseOrdering, bool);
143  itkSetMacro(ReverseOrdering, bool);
144  itkBooleanMacro(ReverseOrdering);
146 
151  itkGetConstMacro(Attribute, AttributeType);
152  itkSetMacro(Attribute, AttributeType);
153  void
154  SetAttribute(const std::string & s)
155  {
156  this->SetAttribute(LabelObjectType::GetAttributeFromName(s));
157  }
159 
161  void
162  SetFeatureImage(const TFeatureImage * input)
163  {
164  // Process object is not const-correct so the const casting is required.
165  this->SetNthInput(1, const_cast<TFeatureImage *>(input));
166  }
167 
169  const FeatureImageType *
171  {
172  return static_cast<const FeatureImageType *>(this->ProcessObject::GetInput(1));
173  }
174 
176  void
177  SetInput1(const InputImageType * input)
178  {
179  this->SetInput(input);
180  }
181 
183  void
185  {
186  this->SetFeatureImage(input);
187  }
188 
189 protected:
191  ~BinaryStatisticsKeepNObjectsImageFilter() override = default;
192  void
193  PrintSelf(std::ostream & os, Indent indent) const override;
194 
198  void
199  GenerateInputRequestedRegion() override;
200 
202  void
203  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
204 
207  void
208  GenerateData() override;
209 
210 private:
211  bool m_FullyConnected{ false };
214  SizeValueType m_NumberOfObjects{ 0 };
215  bool m_ReverseOrdering{ false };
217 }; // end of class
218 } // end namespace itk
219 
220 #ifndef ITK_MANUAL_INSTANTIATION
221 # include "itkBinaryStatisticsKeepNObjectsImageFilter.hxx"
222 #endif
223 
224 #endif
itk::BinaryStatisticsKeepNObjectsImageFilter::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:65
itkStatisticsKeepNObjectsLabelMapFilter.h
itk::BinaryStatisticsKeepNObjectsImageFilter
keep N objects according to their statistics attributes
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:46
itk::BinaryStatisticsKeepNObjectsImageFilter::FeatureImageConstPointer
typename FeatureImageType::ConstPointer FeatureImageConstPointer
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:71
itk::Concept::OStreamWritable
Definition: itkConceptChecking.h:634
itk::StatisticsLabelMapFilter
The valuator class for the StatisticsLabelObject.
Definition: itkStatisticsLabelMapFilter.h:41
itk::BinaryStatisticsKeepNObjectsImageFilter::m_ForegroundValue
OutputImagePixelType m_ForegroundValue
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:213
itkStatisticsLabelMapFilter.h
itk::BinaryStatisticsKeepNObjectsImageFilter::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:67
itk::BinaryStatisticsKeepNObjectsImageFilter::m_Attribute
AttributeType m_Attribute
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:216
itk::LabelMapToBinaryImageFilter
Convert a LabelMap to a binary image.
Definition: itkLabelMapToBinaryImageFilter.h:45
itk::BinaryStatisticsKeepNObjectsImageFilter::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:66
itk::StatisticsLabelObject
A Label object to store the common attributes related to the statistics of the object.
Definition: itkStatisticsLabelObject.h:41
itk::BinaryStatisticsKeepNObjectsImageFilter::SetAttribute
void SetAttribute(const std::string &s)
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:154
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:46
itk::BinaryStatisticsKeepNObjectsImageFilter::SetFeatureImage
void SetFeatureImage(const TFeatureImage *input)
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:162
itk::BinaryStatisticsKeepNObjectsImageFilter::FeatureImagePixelType
typename FeatureImageType::PixelType FeatureImagePixelType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:72
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:70
itk::BinaryStatisticsKeepNObjectsImageFilter::GetFeatureImage
const FeatureImageType * GetFeatureImage()
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:170
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:64
itkLabelMapToBinaryImageFilter.h
itkBinaryImageToLabelMapFilter.h
itk::BinaryStatisticsKeepNObjectsImageFilter::AttributeType
typename LabelObjectType::AttributeType AttributeType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:85
itk::BinaryStatisticsKeepNObjectsImageFilter::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:63
itk::BinaryStatisticsKeepNObjectsImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:60
itk::BinaryStatisticsKeepNObjectsImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:62
itk::BinaryStatisticsKeepNObjectsImageFilter::OutputImageType
TInputImage OutputImageType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:59
itk::BinaryStatisticsKeepNObjectsImageFilter::InputImageType
TInputImage InputImageType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:58
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:61
itk::BinaryStatisticsKeepNObjectsImageFilter::SetInput1
void SetInput1(const InputImageType *input)
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:177
itk::BinaryStatisticsKeepNObjectsImageFilter::m_BackgroundValue
OutputImagePixelType m_BackgroundValue
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:212
itk::Concept::Convertible
Definition: itkConceptChecking.h:214
itk::BinaryStatisticsKeepNObjectsImageFilter::SetInput2
void SetInput2(const FeatureImageType *input)
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:184
itk::StatisticsLabelObject::AttributeType
typename Superclass::AttributeType AttributeType
Definition: itkStatisticsLabelObject.h:80
itk::BinaryStatisticsKeepNObjectsImageFilter::FeatureImagePointer
typename FeatureImageType::Pointer FeatureImagePointer
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:70
itk::BinaryStatisticsKeepNObjectsImageFilter::FeatureImageType
TFeatureImage FeatureImageType
Definition: itkBinaryStatisticsKeepNObjectsImageFilter.h:69
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:79
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:288