ITK  6.0.0
Insight Toolkit
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
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
92
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);
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);
162 itkSetMacro(AutoMinimumMaximum, bool);
163 itkGetConstMacro(AutoMinimumMaximum, bool);
164 itkBooleanMacro(AutoMinimumMaximum);
170 itkSetMacro(MaskOutput, bool);
171 itkGetConstMacro(MaskOutput, bool);
172 itkBooleanMacro(MaskOutput);
178 itkSetMacro(MaskValue, MaskPixelType);
179 itkGetConstMacro(MaskValue, MaskPixelType);
183 itkGetConstMacro(Threshold, InputPixelType);
184
186 itkSetObjectMacro(Calculator, CalculatorType);
187 itkGetModifiableObjectMacro(Calculator, CalculatorType);
190#ifdef ITK_USE_CONCEPT_CHECKING
191 // Begin concept checking
192 itkConceptMacro(OutputEqualityComparableCheck, (Concept::EqualityComparable<OutputPixelType>));
193 itkConceptMacro(InputOStreamWritableCheck, (Concept::OStreamWritable<InputPixelType>));
194 itkConceptMacro(OutputOStreamWritableCheck, (Concept::OStreamWritable<OutputPixelType>));
195 // End concept checking
196#endif
197
198protected:
200 ~HistogramThresholdImageFilter() override = default;
201 void
202 PrintSelf(std::ostream & os, Indent indent) const override;
203
204 void
206 void
207 GenerateData() override;
208
209 void
210 VerifyPreconditions() const override
211 {
212 Superclass::VerifyPreconditions();
213 if (m_Calculator.IsNull())
214 {
215 itkExceptionMacro("No threshold calculator set.");
216 }
217 }
218
219private:
221 void
223
224 OutputPixelType m_InsideValue{};
225 OutputPixelType m_OutsideValue{};
226 InputPixelType m_Threshold{};
227 MaskPixelType m_MaskValue{};
228 CalculatorPointer m_Calculator{};
229 unsigned int m_NumberOfHistogramBins{ 256 };
230 bool m_AutoMinimumMaximum{};
231 bool m_MaskOutput{ true };
232};
233
234} // end namespace itk
235
236#ifndef ITK_MANUAL_INSTANTIATION
237# include "itkHistogramThresholdImageFilter.hxx"
238#endif
239
240#endif
Base class to compute a threshold value based on the histogram of an image.
Threshold an image using a HistogramThresholdCalculator.
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 HistogramType::Pointer HistogramPointer
itkSetInputMacro(MaskImage, TMaskImage)
typename OutputImageType::SizeType OutputSizeType
typename InputImageType::PixelType InputPixelType
typename MaskImageType::SizeType MaskSizeType
typename HistogramType::ConstPointer HistogramConstPointer
itkGetInputMacro(MaskImage, TMaskImage)
void SetUpHistogramGenerator(HistogramGeneratorPointer histogramGenerator)
typename OutputImageType::IndexType OutputIndexType
~HistogramThresholdImageFilter() override=default
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
typename MaskImageType::Pointer MaskImagePointer
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
Base class for all process objects that output image data.
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
typename OutputImageType::Pointer OutputImagePointer
Base class for filters that take an image as input and produce an image as output.
typename InputImageType::Pointer InputImagePointer
typename InputImageType::RegionType InputImageRegionType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Define additional traits for native types such as int or float.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
This class stores measurement vectors in the context of n-dimensional histogram.
Definition: itkHistogram.h:78
TMeasurement MeasurementType
Definition: itkHistogram.h:98
This class generates a histogram from an image.
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....