ITK  6.0.0
Insight Toolkit
itkStatisticsLabelMapFilter.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 itkStatisticsLabelMapFilter_h
19#define itkStatisticsLabelMapFilter_h
20
22
23namespace itk
24{
40template <typename TImage, typename TFeatureImage>
41class ITK_TEMPLATE_EXPORT StatisticsLabelMapFilter
42 : public ShapeLabelMapFilter<TImage, Image<typename TImage::PixelType, TImage::ImageDimension>>
43{
44public:
45 ITK_DISALLOW_COPY_AND_MOVE(StatisticsLabelMapFilter);
46
52
54 using ImageType = TImage;
57 using PixelType = typename ImageType::PixelType;
60 using LabelObjectType = typename ImageType::LabelObjectType;
61 using MatrixType = typename LabelObjectType::MatrixType;
63
64 using FeatureImageType = TFeatureImage;
67 using FeatureImagePixelType = typename FeatureImageType::PixelType;
68
70 static constexpr unsigned int ImageDimension = TImage::ImageDimension;
71
73 itkNewMacro(Self);
74
76 itkOverrideGetNameOfClassMacro(StatisticsLabelMapFilter);
77
78#ifdef ITK_USE_CONCEPT_CHECKING
79 // Begin concept checking
80/* itkConceptMacro(InputEqualityComparableCheck,
81 (Concept::EqualityComparable<InputImagePixelType>));
82 itkConceptMacro(IntConvertibleToInputCheck,
83 (Concept::Convertible<int, InputImagePixelType>));
84 itkConceptMacro(InputOStreamWritableCheck,
85 (Concept::OStreamWritable<InputImagePixelType>));*/
86// End concept checking
87#endif
88
90 void
91 SetFeatureImage(const TFeatureImage * input)
92 {
93 // Process object is not const-correct so the const casting is required.
94 this->SetNthInput(1, const_cast<TFeatureImage *>(input));
95 }
96
98 FeatureImageType *
100 {
101 return static_cast<FeatureImageType *>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
102 }
103
105 void
106 SetInput1(TImage * input)
107 {
108 this->SetInput(input);
109 }
110
112 void
113 SetInput2(const TFeatureImage * input)
114 {
115 this->SetFeatureImage(input);
116 }
117
124 itkSetMacro(ComputeHistogram, bool);
125 itkGetConstReferenceMacro(ComputeHistogram, bool);
126 itkBooleanMacro(ComputeHistogram);
134 itkSetMacro(NumberOfBins, unsigned int);
135 itkGetConstReferenceMacro(NumberOfBins, unsigned int);
138 // Set the default number of bins to match the number of values for 8 or 16-bit integers; otherwise 128
139 static constexpr unsigned int
141 {
142 constexpr size_t bitsShift = std::min(8 * sizeof(FeatureImagePixelType), 8 * sizeof(m_NumberOfBins) - 1);
143
144 return std::is_integral_v<FeatureImagePixelType> && sizeof(FeatureImagePixelType) <= 2 ? 1u << bitsShift : 128u;
145 }
146
147protected:
149 ~StatisticsLabelMapFilter() override = default;
150
151 void
153
154 void
156
157 void
158 PrintSelf(std::ostream & os, Indent indent) const override;
159
160private:
163 unsigned int m_NumberOfBins{ GetDefaultNumberOfBins() };
164 bool m_ComputeHistogram{ true };
165}; // end of class
166} // end namespace itk
167
168#ifndef ITK_MANUAL_INSTANTIATION
169# include "itkStatisticsLabelMapFilter.hxx"
170#endif
171
172#endif
Base class for all data objects in ITK.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
The valuator class for the ShapeLabelObject.
The valuator class for the StatisticsLabelObject.
typename ImageType::LabelObjectType LabelObjectType
void BeforeThreadedGenerateData() override
static constexpr unsigned int GetDefaultNumberOfBins()
typename FeatureImageType::PixelType FeatureImagePixelType
void SetFeatureImage(const TFeatureImage *input)
typename LabelObjectType::MatrixType MatrixType
~StatisticsLabelMapFilter() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
typename FeatureImageType::Pointer FeatureImagePointer
typename ImageType::ConstPointer ImageConstPointer
void ThreadedProcessLabelObject(LabelObjectType *labelObject) override
typename ImageType::IndexType IndexType
typename ImageType::PixelType PixelType
typename FeatureImageType::ConstPointer FeatureImageConstPointer
void SetInput2(const TFeatureImage *input)
typename ImageType::PointType PointType
typename ImageType::Pointer ImagePointer
typename LabelObjectType::VectorType VectorType
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....