ITK  5.1.0
Insight Toolkit
itkBinaryShapeKeepNObjectsImageFilter.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 itkBinaryShapeKeepNObjectsImageFilter_h
19 #define itkBinaryShapeKeepNObjectsImageFilter_h
20 
21 #include "itkShapeLabelObject.h"
23 #include "itkShapeLabelMapFilter.h"
26 
27 namespace itk
28 {
47 template <typename TInputImage>
48 class ITK_TEMPLATE_EXPORT BinaryShapeKeepNObjectsImageFilter : public ImageToImageFilter<TInputImage, TInputImage>
49 {
50 public:
51  ITK_DISALLOW_COPY_AND_ASSIGN(BinaryShapeKeepNObjectsImageFilter);
52 
58 
60  using InputImageType = TInputImage;
61  using OutputImageType = TInputImage;
62  using InputImagePointer = typename InputImageType::Pointer;
63  using InputImageConstPointer = typename InputImageType::ConstPointer;
65  using InputImagePixelType = typename InputImageType::PixelType;
66  using OutputImagePointer = typename OutputImageType::Pointer;
67  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
69  using OutputImagePixelType = typename OutputImageType::PixelType;
70 
72  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
73  static constexpr unsigned int OutputImageDimension = TInputImage::ImageDimension;
74  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
75 
77 
86 
88  itkNewMacro(Self);
89 
92 
99  itkSetMacro(FullyConnected, bool);
100  itkGetConstReferenceMacro(FullyConnected, bool);
101  itkBooleanMacro(FullyConnected);
103 
104 #ifdef ITK_USE_CONCEPT_CHECKING
105  // Begin concept checking
106  itkConceptMacro(InputEqualityComparableCheck, (Concept::EqualityComparable<InputImagePixelType>));
109  // End concept checking
110 #endif
111 
116  itkSetMacro(BackgroundValue, OutputImagePixelType);
117  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
119 
124  itkSetMacro(ForegroundValue, OutputImagePixelType);
125  itkGetConstMacro(ForegroundValue, OutputImagePixelType);
127 
131  itkGetConstMacro(NumberOfObjects, SizeValueType);
132  itkSetMacro(NumberOfObjects, SizeValueType);
134 
140  itkGetConstMacro(ReverseOrdering, bool);
141  itkSetMacro(ReverseOrdering, bool);
142  itkBooleanMacro(ReverseOrdering);
144 
149  itkGetConstMacro(Attribute, AttributeType);
150  itkSetMacro(Attribute, AttributeType);
151  void
152  SetAttribute(const std::string & s)
153  {
154  this->SetAttribute(LabelObjectType::GetAttributeFromName(s));
155  }
157 
158 protected:
160  ~BinaryShapeKeepNObjectsImageFilter() override = default;
161  void
162  PrintSelf(std::ostream & os, Indent indent) const override;
163 
167  void
168  GenerateInputRequestedRegion() override;
169 
171  void
172  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
173 
176  void
177  GenerateData() override;
178 
179 private:
180  bool m_FullyConnected{ false };
183  SizeValueType m_NumberOfObjects{ 0 };
184  bool m_ReverseOrdering{ false };
186 }; // end of class
187 } // end namespace itk
188 
189 #ifndef ITK_MANUAL_INSTANTIATION
190 # include "itkBinaryShapeKeepNObjectsImageFilter.hxx"
191 #endif
192 
193 #endif
itk::BinaryShapeKeepNObjectsImageFilter
keep N objects according to their shape attributes
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:48
itk::BinaryShapeKeepNObjectsImageFilter::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:67
itk::Concept::OStreamWritable
Definition: itkConceptChecking.h:634
itk::BinaryShapeKeepNObjectsImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:62
itk::LabelMapToBinaryImageFilter
Convert a LabelMap to a binary image.
Definition: itkLabelMapToBinaryImageFilter.h:46
itk::BinaryShapeKeepNObjectsImageFilter::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:69
itk::ShapeKeepNObjectsLabelMapFilter
Keep N objects according to their shape attributes.
Definition: itkShapeKeepNObjectsLabelMapFilter.h:45
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ShapeLabelMapFilter
The valuator class for the ShapeLabelObject.
Definition: itkShapeLabelMapFilter.h:54
itk::BinaryShapeKeepNObjectsImageFilter::m_ForegroundValue
OutputImagePixelType m_ForegroundValue
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:182
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
itkShapeLabelMapFilter.h
itk::BinaryShapeKeepNObjectsImageFilter::OutputImageType
TInputImage OutputImageType
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:61
itkShapeLabelObject.h
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::BinaryShapeKeepNObjectsImageFilter::InputImageConstPointer
typename InputImageType::ConstPointer InputImageConstPointer
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:63
itkShapeKeepNObjectsLabelMapFilter.h
itkLabelMapToBinaryImageFilter.h
itkBinaryImageToLabelMapFilter.h
itk::BinaryShapeKeepNObjectsImageFilter::SetAttribute
void SetAttribute(const std::string &s)
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:152
itk::BinaryShapeKeepNObjectsImageFilter::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:66
itk::BinaryShapeKeepNObjectsImageFilter::m_BackgroundValue
OutputImagePixelType m_BackgroundValue
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:181
itk::BinaryShapeKeepNObjectsImageFilter::InputImageType
TInputImage InputImageType
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:60
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::ShapeLabelObject
A Label object to store the common attributes related to the shape of the object.
Definition: itkShapeLabelObject.h:44
itk::BinaryShapeKeepNObjectsImageFilter::m_Attribute
AttributeType m_Attribute
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:185
itk::Concept::Convertible
Definition: itkConceptChecking.h:214
itk::BinaryShapeKeepNObjectsImageFilter::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:65
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itk::ShapeLabelObject::AttributeType
typename Superclass::AttributeType AttributeType
Definition: itkShapeLabelObject.h:75
itk::BinaryShapeKeepNObjectsImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:64
itk::BinaryShapeKeepNObjectsImageFilter::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:68
itk::BinaryShapeKeepNObjectsImageFilter::LabelType
SizeValueType LabelType
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:76
itk::Concept::EqualityComparable
Definition: itkConceptChecking.h:304
itk::BinaryShapeKeepNObjectsImageFilter::AttributeType
typename LabelObjectType::AttributeType AttributeType
Definition: itkBinaryShapeKeepNObjectsImageFilter.h:83
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293