ITK  5.4.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 * 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 itkBinaryStatisticsKeepNObjectsImageFilter_h
19#define itkBinaryStatisticsKeepNObjectsImageFilter_h
20
25
26namespace itk
27{
45template <typename TInputImage, typename TFeatureImage>
46class ITK_TEMPLATE_EXPORT BinaryStatisticsKeepNObjectsImageFilter : public ImageToImageFilter<TInputImage, TInputImage>
47{
48public:
49 ITK_DISALLOW_COPY_AND_MOVE(BinaryStatisticsKeepNObjectsImageFilter);
50
56
58 using InputImageType = TInputImage;
59 using OutputImageType = TInputImage;
63 using InputImagePixelType = typename InputImageType::PixelType;
67 using OutputImagePixelType = typename OutputImageType::PixelType;
68
69 using FeatureImageType = TFeatureImage;
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
93 itkOverrideGetNameOfClassMacro(BinaryStatisticsKeepNObjectsImageFilter);
94
101 itkSetMacro(FullyConnected, bool);
102 itkGetConstReferenceMacro(FullyConnected, bool);
103 itkBooleanMacro(FullyConnected);
106#ifdef ITK_USE_CONCEPT_CHECKING
107 // Begin concept checking
111 // End concept checking
112#endif
113
118 itkSetMacro(BackgroundValue, OutputImagePixelType);
119 itkGetConstMacro(BackgroundValue, OutputImagePixelType);
126 itkSetMacro(ForegroundValue, OutputImagePixelType);
127 itkGetConstMacro(ForegroundValue, OutputImagePixelType);
133 itkGetConstMacro(NumberOfObjects, SizeValueType);
134 itkSetMacro(NumberOfObjects, SizeValueType);
142 itkGetConstMacro(ReverseOrdering, bool);
143 itkSetMacro(ReverseOrdering, bool);
144 itkBooleanMacro(ReverseOrdering);
151 itkGetConstMacro(Attribute, AttributeType);
152 itkSetMacro(Attribute, AttributeType);
153 void
154 SetAttribute(const std::string & s)
155 {
156 this->SetAttribute(LabelObjectType::GetAttributeFromName(s));
157 }
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
178 {
179 this->SetInput(input);
180 }
181
183 void
185 {
186 this->SetFeatureImage(input);
187 }
188
189protected:
192 void
193 PrintSelf(std::ostream & os, Indent indent) const override;
194
198 void
200
202 void
203 EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
204
207 void
208 GenerateData() override;
209
210private:
211 bool m_FullyConnected{ false };
212 OutputImagePixelType m_BackgroundValue{};
213 OutputImagePixelType m_ForegroundValue{};
214 SizeValueType m_NumberOfObjects{ 0 };
215 bool m_ReverseOrdering{ false };
216 AttributeType m_Attribute{};
217}; // end of class
218} // end namespace itk
219
220#ifndef ITK_MANUAL_INSTANTIATION
221# include "itkBinaryStatisticsKeepNObjectsImageFilter.hxx"
222#endif
223
224#endif
Label the connected components in a binary image and produce a collection of label objects.
keep N objects according to their statistics attributes
void PrintSelf(std::ostream &os, Indent indent) const override
~BinaryStatisticsKeepNObjectsImageFilter() override=default
void EnlargeOutputRequestedRegion(DataObject *) override
Base class for all data objects in ITK.
Base class for filters that take an image as input and produce an image as output.
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.
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
keep N objects according to their statistics attributes
The valuator class for the StatisticsLabelObject.
A Label object to store the common attributes related to the statistics 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:83