ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkHistogramThresholdImageFilter.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
19#ifndef itkHistogramThresholdImageFilter_h
20#define itkHistogramThresholdImageFilter_h
21
24#include "itkHistogram.h"
26
27namespace itk
28{
29
60
61template <typename TInputImage, typename TOutputImage, typename TMaskImage = TOutputImage>
62class ITK_TEMPLATE_EXPORT HistogramThresholdImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
63{
64public:
65 ITK_DISALLOW_COPY_AND_MOVE(HistogramThresholdImageFilter);
66
72
74 itkNewMacro(Self);
75
77 itkOverrideGetNameOfClassMacro(HistogramThresholdImageFilter);
78
79 using InputImageType = TInputImage;
80 using OutputImageType = TOutputImage;
81 using MaskImageType = TMaskImage;
82
84 using InputPixelType = typename InputImageType::PixelType;
85 using OutputPixelType = typename OutputImageType::PixelType;
86 using MaskPixelType = typename MaskImageType::PixelType;
87
89 using InputImagePointer = typename InputImageType::Pointer;
90 using OutputImagePointer = typename OutputImageType::Pointer;
91 using MaskImagePointer = typename MaskImageType::Pointer;
92
93 using InputSizeType = typename InputImageType::SizeType;
94 using InputIndexType = typename InputImageType::IndexType;
95 using InputImageRegionType = typename InputImageType::RegionType;
96 using OutputSizeType = typename OutputImageType::SizeType;
97 using OutputIndexType = typename OutputImageType::IndexType;
98 using OutputImageRegionType = typename OutputImageType::RegionType;
99 using MaskSizeType = typename MaskImageType::SizeType;
100 using MaskIndexType = typename MaskImageType::IndexType;
101 using MaskImageRegionType = typename MaskImageType::RegionType;
102
113
116
118 static constexpr unsigned int InputImageDimension = InputImageType::ImageDimension;
119 static constexpr unsigned int OutputImageDimension = OutputImageType::ImageDimension;
120 static constexpr unsigned int MaskImageDimension = MaskImageType::ImageDimension;
121
123 itkSetInputMacro(MaskImage, TMaskImage);
124 itkGetInputMacro(MaskImage, TMaskImage);
126
128 void
129 SetInput1(const TInputImage * input)
130 {
131 this->SetInput(input);
132 }
133
135 void
136 SetInput2(const TMaskImage * input)
137 {
138 this->SetMaskImage(input);
139 }
140
143 itkSetMacro(OutsideValue, OutputPixelType);
144
146 itkGetConstMacro(OutsideValue, OutputPixelType);
147
150 itkSetMacro(InsideValue, OutputPixelType);
151
153 itkGetConstMacro(InsideValue, OutputPixelType);
154
156 itkSetMacro(NumberOfHistogramBins, unsigned int);
157 itkGetConstMacro(NumberOfHistogramBins, unsigned int);
159
162 itkSetMacro(AutoMinimumMaximum, bool);
163 itkGetConstMacro(AutoMinimumMaximum, bool);
164 itkBooleanMacro(AutoMinimumMaximum);
166
170 itkSetMacro(MaskOutput, bool);
171 itkGetConstMacro(MaskOutput, bool);
172 itkBooleanMacro(MaskOutput);
174
178 itkSetMacro(MaskValue, MaskPixelType);
179 itkGetConstMacro(MaskValue, MaskPixelType);
181
183 itkGetConstMacro(Threshold, InputPixelType);
184
186 itkSetObjectMacro(Calculator, CalculatorType);
187 itkGetModifiableObjectMacro(Calculator, CalculatorType);
189
190 itkConceptMacro(OutputEqualityComparableCheck, (Concept::EqualityComparable<OutputPixelType>));
191 itkConceptMacro(InputOStreamWritableCheck, (Concept::OStreamWritable<InputPixelType>));
192 itkConceptMacro(OutputOStreamWritableCheck, (Concept::OStreamWritable<OutputPixelType>));
193
194protected:
196 ~HistogramThresholdImageFilter() override = default;
197 void
198 PrintSelf(std::ostream & os, Indent indent) const override;
199
200 void
202 void
203 GenerateData() override;
204
205 void
206 VerifyPreconditions() const override
207 {
209 if (m_Calculator.IsNull())
210 {
211 itkExceptionMacro("No threshold calculator set.");
212 }
213 }
214
215private:
217 void
219
225 unsigned int m_NumberOfHistogramBins{ 256 };
227 bool m_MaskOutput{ true };
228};
229
230} // end namespace itk
231
232#ifndef ITK_MANUAL_INSTANTIATION
233# include "itkHistogramThresholdImageFilter.hxx"
234#endif
235
236#endif
Base class to compute a threshold value based on the histogram of an image.
typename MaskImageType::RegionType MaskImageRegionType
typename NumericTraits< ValueType >::RealType ValueRealType
typename InputImageType::IndexType InputIndexType
typename HistogramType::MeasurementVectorType HistogramMeasurementVectorType
void GenerateInputRequestedRegion() override
typename HistogramType::SizeType HistogramSizeType
typename OutputImageType::Pointer OutputImagePointer
typename InputImageType::RegionType InputImageRegionType
itkSetInputMacro(MaskImage, TMaskImage)
typename InputImageType::Pointer InputImagePointer
HistogramThresholdCalculator< HistogramType, InputPixelType > CalculatorType
typename OutputImageType::SizeType OutputSizeType
Statistics::ImageToHistogramFilter< InputImageType > HistogramGeneratorType
typename InputImageType::PixelType InputPixelType
typename HistogramType::ConstPointer HistogramConstPointer
itkGetInputMacro(MaskImage, TMaskImage)
void SetUpHistogramGenerator(HistogramGeneratorPointer histogramGenerator)
ImageToImageFilter< TInputImage, TOutputImage > Superclass
typename OutputImageType::IndexType OutputIndexType
~HistogramThresholdImageFilter() override=default
typename OutputImageType::RegionType OutputImageRegionType
typename MaskImageType::IndexType MaskIndexType
void VerifyPreconditions() const override
Verifies that the process object has been configured correctly, that all required inputs are set,...
typename HistogramGeneratorType::Pointer HistogramGeneratorPointer
Statistics::Histogram< ValueRealType > HistogramType
typename OutputImageType::PixelType OutputPixelType
typename InputImageType::SizeType InputSizeType
typename HistogramType::MeasurementType HistogramMeasurementType
void PrintSelf(std::ostream &os, Indent indent) const override
typename MaskImageType::PixelType MaskPixelType
typename NumericTraits< InputPixelType >::ValueType ValueType
typename CalculatorType::Pointer CalculatorPointer
virtual void SetInput(const InputImageType *input)
Control indentation during Print() invocation.
Definition itkIndent.h:50
virtual void VerifyPreconditions() const
Verifies that the process object has been configured correctly, that all required inputs are set,...
Implements transparent reference counting.
This class stores measurement vectors in the context of n-dimensional histogram.
SmartPointer< const Self > ConstPointer
This class generates a histogram from an image.
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....