ITK  6.0.0
Insight Toolkit
itkOtsuMultipleThresholdsCalculator.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 itkOtsuMultipleThresholdsCalculator_h
19#define itkOtsuMultipleThresholdsCalculator_h
20
22#include "itkHistogram.h"
23
24namespace itk
25{
49template <typename TInputHistogram>
50class ITK_TEMPLATE_EXPORT OtsuMultipleThresholdsCalculator : public HistogramAlgorithmBase<TInputHistogram>
51{
52public:
58
59 using MeasurementType = typename TInputHistogram::MeasurementType;
60 using FrequencyType = typename TInputHistogram::AbsoluteFrequencyType;
61
65
66 using MeanVectorType = std::vector<MeanType>;
67 using FrequencyVectorType = std::vector<FrequencyType>;
68 using WeightVectorType = std::vector<WeightType>;
69
70 using InstanceIdentifierType = typename TInputHistogram::InstanceIdentifier;
71 using InstanceIdentifierVectorType = std::vector<InstanceIdentifierType>;
72
74 itkOverrideGetNameOfClassMacro(OtsuMultipleThresholdsCalculator);
75 itkNewMacro(Self);
79 using OutputType = std::vector<MeasurementType>;
80
82 const OutputType &
84
86 itkSetClampMacro(NumberOfThresholds, SizeValueType, 1, NumericTraits<SizeValueType>::max());
87 itkGetConstMacro(NumberOfThresholds, SizeValueType);
91 void
92 Compute() override;
93
95 itkSetMacro(ValleyEmphasis, bool);
96 itkGetConstReferenceMacro(ValleyEmphasis, bool);
97 itkBooleanMacro(ValleyEmphasis);
102 itkSetMacro(ReturnBinMidpoint, bool);
103 itkGetConstReferenceMacro(ReturnBinMidpoint, bool);
104 itkBooleanMacro(ReturnBinMidpoint);
108protected:
111 void
112 PrintSelf(std::ostream & os, Indent indent) const override;
113
115 bool
117 MeanType globalMean,
118 MeanVectorType & classMean,
119 FrequencyVectorType & classFrequency);
120
121private:
122 SizeValueType m_NumberOfThresholds{ 1 };
123 OutputType m_Output{};
124 bool m_ValleyEmphasis{ false };
125 bool m_ReturnBinMidpoint{ false };
126};
127} // end of namespace itk
128
129#ifndef ITK_MANUAL_INSTANTIATION
130# include "itkOtsuMultipleThresholdsCalculator.hxx"
131#endif
132
133#endif
base class for algorithms operating on histograms
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Define additional traits for native types such as int or float.
Computes Otsu's multiple thresholds for a histogram.
typename NumericTraits< MeasurementType >::RealType MeanType
~OtsuMultipleThresholdsCalculator() override=default
typename NumericTraits< MeasurementType >::RealType WeightType
typename TInputHistogram::AbsoluteFrequencyType FrequencyType
std::vector< InstanceIdentifierType > InstanceIdentifierVectorType
typename TInputHistogram::MeasurementType MeasurementType
typename NumericTraits< MeasurementType >::RealType VarianceType
void PrintSelf(std::ostream &os, Indent indent) const override
typename TInputHistogram::InstanceIdentifier InstanceIdentifierType
bool IncrementThresholds(InstanceIdentifierVectorType &thresholdIndexes, MeanType globalMean, MeanVectorType &classMean, FrequencyVectorType &classFrequency)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86