ITK  6.0.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 * 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 itkBinaryShapeKeepNObjectsImageFilter_h
19#define itkBinaryShapeKeepNObjectsImageFilter_h
20
21#include "itkShapeLabelObject.h"
26
27namespace itk
28{
46template <typename TInputImage>
47class ITK_TEMPLATE_EXPORT BinaryShapeKeepNObjectsImageFilter : public ImageToImageFilter<TInputImage, TInputImage>
48{
49public:
50 ITK_DISALLOW_COPY_AND_MOVE(BinaryShapeKeepNObjectsImageFilter);
51
57
59 using InputImageType = TInputImage;
60 using OutputImageType = TInputImage;
64 using InputImagePixelType = typename InputImageType::PixelType;
68 using OutputImagePixelType = typename OutputImageType::PixelType;
69
71 static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
72 static constexpr unsigned int OutputImageDimension = TInputImage::ImageDimension;
73 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
74
76
85
87 itkNewMacro(Self);
88
90 itkOverrideGetNameOfClassMacro(BinaryShapeKeepNObjectsImageFilter);
91
98 itkSetMacro(FullyConnected, bool);
99 itkGetConstReferenceMacro(FullyConnected, bool);
100 itkBooleanMacro(FullyConnected);
103#ifdef ITK_USE_CONCEPT_CHECKING
104 // Begin concept checking
108 // End concept checking
109#endif
110
115 itkSetMacro(BackgroundValue, OutputImagePixelType);
116 itkGetConstMacro(BackgroundValue, OutputImagePixelType);
123 itkSetMacro(ForegroundValue, OutputImagePixelType);
124 itkGetConstMacro(ForegroundValue, OutputImagePixelType);
130 itkGetConstMacro(NumberOfObjects, SizeValueType);
131 itkSetMacro(NumberOfObjects, SizeValueType);
139 itkGetConstMacro(ReverseOrdering, bool);
140 itkSetMacro(ReverseOrdering, bool);
141 itkBooleanMacro(ReverseOrdering);
148 itkGetConstMacro(Attribute, AttributeType);
149 itkSetMacro(Attribute, AttributeType);
150 void
151 SetAttribute(const std::string & s)
152 {
153 this->SetAttribute(LabelObjectType::GetAttributeFromName(s));
154 }
157protected:
160 void
161 PrintSelf(std::ostream & os, Indent indent) const override;
162
166 void
168
170 void
171 EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
172
175 void
176 GenerateData() override;
177
178private:
179 bool m_FullyConnected{ false };
180 OutputImagePixelType m_BackgroundValue{};
181 OutputImagePixelType m_ForegroundValue{};
182 SizeValueType m_NumberOfObjects{ 0 };
183 bool m_ReverseOrdering{ false };
184 AttributeType m_Attribute{};
185}; // end of class
186} // end namespace itk
187
188#ifndef ITK_MANUAL_INSTANTIATION
189# include "itkBinaryShapeKeepNObjectsImageFilter.hxx"
190#endif
191
192#endif
Label the connected components in a binary image and produce a collection of label objects.
keep N objects according to their shape attributes
typename InputImageType::ConstPointer InputImageConstPointer
typename OutputImageType::RegionType OutputImageRegionType
void PrintSelf(std::ostream &os, Indent indent) const override
void EnlargeOutputRequestedRegion(DataObject *) override
typename OutputImageType::ConstPointer OutputImageConstPointer
~BinaryShapeKeepNObjectsImageFilter() override=default
typename LabelObjectType::AttributeType AttributeType
Base class for all data objects in ITK.
Base class for filters that take an image as input and produce an image as output.
Templated n-dimensional image class.
Definition: itkImage.h:89
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Convert a LabelMap to a binary image.
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:71
unsigned int AttributeType
Light weight base class for most itk classes.
Keep N objects according to their shape attributes.
The valuator class for the ShapeLabelObject.
A Label object to store the common attributes related to the shape of the object.
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86