ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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;
55 using ImagePointer = typename ImageType::Pointer;
56 using ImageConstPointer = typename ImageType::ConstPointer;
57 using PixelType = typename ImageType::PixelType;
58 using IndexType = typename ImageType::IndexType;
59 using PointType = typename ImageType::PointType;
60 using LabelObjectType = typename ImageType::LabelObjectType;
61 using MatrixType = typename LabelObjectType::MatrixType;
62 using VectorType = typename LabelObjectType::VectorType;
63
64 using FeatureImageType = TFeatureImage;
65 using FeatureImagePointer = typename FeatureImageType::Pointer;
66 using FeatureImageConstPointer = typename FeatureImageType::ConstPointer;
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 /*itkConceptMacro(InputEqualityComparableCheck,
79 (Concept::EqualityComparable<InputImagePixelType>));
80 itkConceptMacro(IntConvertibleToInputCheck,
81 (Concept::Convertible<int, InputImagePixelType>));
82 itkConceptMacro(InputOStreamWritableCheck,
83 (Concept::OStreamWritable<InputImagePixelType>));*/
84
86 void
87 SetFeatureImage(const TFeatureImage * input)
88 {
89 // Process object is not const-correct so the const casting is required.
90 this->SetNthInput(1, const_cast<TFeatureImage *>(input));
91 }
92
94 FeatureImageType *
96 {
97 return static_cast<FeatureImageType *>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
98 }
99
101 void
102 SetInput1(TImage * input)
103 {
104 this->SetInput(input);
105 }
106
108 void
109 SetInput2(const TFeatureImage * input)
110 {
111 this->SetFeatureImage(input);
112 }
113
120 itkSetMacro(ComputeHistogram, bool);
121 itkGetConstReferenceMacro(ComputeHistogram, bool);
122 itkBooleanMacro(ComputeHistogram);
124
130 itkSetMacro(NumberOfBins, unsigned int);
131 itkGetConstReferenceMacro(NumberOfBins, unsigned int);
133
134 // Set the default number of bins to match the number of values for 8 or 16-bit integers; otherwise 128
135 static constexpr unsigned int
137 {
138 constexpr size_t bitsShift = std::min(8 * sizeof(FeatureImagePixelType), 8 * sizeof(m_NumberOfBins) - 1);
139
140 return std::is_integral_v<FeatureImagePixelType> && sizeof(FeatureImagePixelType) <= 2 ? 1u << bitsShift : 128u;
141 }
142
143protected:
145 ~StatisticsLabelMapFilter() override = default;
146
147 void
149
150 void
152
153 void
154 PrintSelf(std::ostream & os, Indent indent) const override;
155
156private:
160 bool m_ComputeHistogram{ true };
161}; // end of class
162} // end namespace itk
163
164#ifndef ITK_MANUAL_INSTANTIATION
165# include "itkStatisticsLabelMapFilter.hxx"
166#endif
167
168#endif
Base class for all data objects in ITK.
virtual void SetInput(const InputImageType *input)
Control indentation during Print() invocation.
Definition itkIndent.h:50
virtual void SetNthInput(DataObjectPointerArraySizeType idx, DataObject *input)
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Implements transparent reference counting.
void BeforeThreadedGenerateData() override
static constexpr unsigned int GetDefaultNumberOfBins()
void SetFeatureImage(const TFeatureImage *input)
~StatisticsLabelMapFilter() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
void ThreadedProcessLabelObject(LabelObjectType *labelObject) override
void SetInput2(const TFeatureImage *input)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....