ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkOtsuThresholdImageFilter.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 itkOtsuThresholdImageFilter_h
20#define itkOtsuThresholdImageFilter_h
21
24
25namespace itk
26{
27
53
54template <typename TInputImage, typename TOutputImage, typename TMaskImage = TOutputImage>
55class ITK_TEMPLATE_EXPORT OtsuThresholdImageFilter
56 : public HistogramThresholdImageFilter<TInputImage, TOutputImage, TMaskImage>
57{
58public:
59 ITK_DISALLOW_COPY_AND_MOVE(OtsuThresholdImageFilter);
60
66
68 itkNewMacro(Self);
69
71 itkOverrideGetNameOfClassMacro(OtsuThresholdImageFilter);
72
73 using InputImageType = TInputImage;
74 using OutputImageType = TOutputImage;
75 using MaskImageType = TMaskImage;
76
78 using InputPixelType = typename InputImageType::PixelType;
79 using OutputPixelType = typename OutputImageType::PixelType;
80 using MaskPixelType = typename MaskImageType::PixelType;
81
83 using InputImagePointer = typename InputImageType::Pointer;
84 using OutputImagePointer = typename OutputImageType::Pointer;
85
86 using InputSizeType = typename InputImageType::SizeType;
87 using InputIndexType = typename InputImageType::IndexType;
88 using InputImageRegionType = typename InputImageType::RegionType;
89 using OutputSizeType = typename OutputImageType::SizeType;
90 using OutputIndexType = typename OutputImageType::IndexType;
91 using OutputImageRegionType = typename OutputImageType::RegionType;
92 using MaskSizeType = typename MaskImageType::SizeType;
93 using MaskIndexType = typename MaskImageType::IndexType;
94 using MaskImageRegionType = typename MaskImageType::RegionType;
95
96 using typename Superclass::HistogramType;
98
100 static constexpr unsigned int InputImageDimension = InputImageType::ImageDimension;
101 static constexpr unsigned int OutputImageDimension = OutputImageType::ImageDimension;
102
105 itkSetMacro(ReturnBinMidpoint, bool);
106 itkGetConstReferenceMacro(ReturnBinMidpoint, bool);
107 itkBooleanMacro(ReturnBinMidpoint);
109
110protected:
112 ~OtsuThresholdImageFilter() override = default;
113
114 void
115 GenerateData() override
116 {
117 auto calc = static_cast<CalculatorType *>(this->GetModifiableCalculator());
118 calc->SetReturnBinMidpoint(m_ReturnBinMidpoint);
120 }
121
122 void
123 VerifyPreconditions() const override
124 {
126 if (dynamic_cast<const CalculatorType *>(Superclass::GetCalculator()) == nullptr)
127 {
128 itkExceptionMacro("Invalid OtsuThresholdCalculator.");
129 }
130 }
131
132private:
133 bool m_ReturnBinMidpoint{ false };
134};
135
136} // end namespace itk
137
138#endif
Computes the Otsu's threshold for an image.
static constexpr unsigned int OutputImageDimension
typename OutputImageType::IndexType OutputIndexType
typename OutputImageType::SizeType OutputSizeType
typename OutputImageType::PixelType OutputPixelType
typename OutputImageType::RegionType OutputImageRegionType
~OtsuThresholdImageFilter() override=default
typename MaskImageType::SizeType MaskSizeType
typename MaskImageType::RegionType MaskImageRegionType
OtsuThresholdCalculator< HistogramType, InputPixelType > CalculatorType
typename InputImageType::PixelType InputPixelType
typename InputImageType::Pointer InputImagePointer
typename MaskImageType::PixelType MaskPixelType
typename InputImageType::IndexType InputIndexType
SmartPointer< const Self > ConstPointer
typename OutputImageType::Pointer OutputImagePointer
typename MaskImageType::IndexType MaskIndexType
void VerifyPreconditions() const override
Verifies that the process object has been configured correctly, that all required inputs are set,...
typename InputImageType::SizeType InputSizeType
HistogramThresholdImageFilter< TInputImage, TOutputImage, TMaskImage > Superclass
typename InputImageType::RegionType InputImageRegionType
static constexpr unsigned int InputImageDimension
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....