ITK  6.0.0
Insight Toolkit
itkLabelShapeKeepNObjectsImageFilter.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 itkLabelShapeKeepNObjectsImageFilter_h
19#define itkLabelShapeKeepNObjectsImageFilter_h
20
21#include "itkShapeLabelObject.h"
26
27namespace itk
28{
50template <typename TInputImage>
51class ITK_TEMPLATE_EXPORT LabelShapeKeepNObjectsImageFilter : public ImageToImageFilter<TInputImage, TInputImage>
52{
53public:
54 ITK_DISALLOW_COPY_AND_MOVE(LabelShapeKeepNObjectsImageFilter);
55
61
63 using InputImageType = TInputImage;
64 using OutputImageType = TInputImage;
68 using InputImagePixelType = typename InputImageType::PixelType;
72 using OutputImagePixelType = typename OutputImageType::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
87
89 itkNewMacro(Self);
90
92 itkOverrideGetNameOfClassMacro(LabelShapeKeepNObjectsImageFilter);
93
94#ifdef ITK_USE_CONCEPT_CHECKING
95 // Begin concept checking
99 // End concept checking
100#endif
101
106 itkSetMacro(BackgroundValue, OutputImagePixelType);
107 itkGetConstMacro(BackgroundValue, OutputImagePixelType);
113 itkGetConstMacro(NumberOfObjects, SizeValueType);
114 itkSetMacro(NumberOfObjects, SizeValueType);
122 itkGetConstMacro(ReverseOrdering, bool);
123 itkSetMacro(ReverseOrdering, bool);
124 itkBooleanMacro(ReverseOrdering);
131 itkGetConstMacro(Attribute, AttributeType);
132 itkSetMacro(Attribute, AttributeType);
133 void
134 SetAttribute(const std::string & s)
135 {
136 this->SetAttribute(LabelObjectType::GetAttributeFromName(s));
137 }
140protected:
143 void
144 PrintSelf(std::ostream & os, Indent indent) const override;
145
149 void
151
153 void
154 EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
155
158 void
159 GenerateData() override;
160
161private:
162 OutputImagePixelType m_BackgroundValue{};
163 SizeValueType m_NumberOfObjects{};
164 bool m_ReverseOrdering{};
165 AttributeType m_Attribute{};
166}; // end of class
167} // end namespace itk
168
169#ifndef ITK_MANUAL_INSTANTIATION
170# include "itkLabelShapeKeepNObjectsImageFilter.hxx"
171#endif
172
173#endif
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 labeled image to a label collection image
Converts a LabelMap to a labeled image.
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:71
unsigned int AttributeType
keep N objects according to their shape attributes
typename OutputImageType::RegionType OutputImageRegionType
typename OutputImageType::ConstPointer OutputImageConstPointer
typename OutputImageType::PixelType OutputImagePixelType
typename InputImageType::ConstPointer InputImageConstPointer
void PrintSelf(std::ostream &os, Indent indent) const override
typename InputImageType::RegionType InputImageRegionType
~LabelShapeKeepNObjectsImageFilter() override=default
void EnlargeOutputRequestedRegion(DataObject *) override
typename LabelObjectType::AttributeType 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