ITK  5.2.0
Insight Toolkit
itkOtsuMultipleThresholdsImageFilter.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  * http://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 itkOtsuMultipleThresholdsImageFilter_h
19 #define itkOtsuMultipleThresholdsImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 #include "itkFixedArray.h"
25 
26 namespace itk
27 {
60 template <typename TInputImage, typename TOutputImage>
61 class ITK_TEMPLATE_EXPORT OtsuMultipleThresholdsImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
62 {
63 public:
64  ITK_DISALLOW_COPY_AND_MOVE(OtsuMultipleThresholdsImageFilter);
65 
71 
73  itkNewMacro(Self);
74 
77 
79  using InputPixelType = typename TInputImage::PixelType;
80  using OutputPixelType = typename TOutputImage::PixelType;
81 
83  using InputImagePointer = typename TInputImage::Pointer;
84  using OutputImagePointer = typename TOutputImage::Pointer;
85 
92 
98 
100  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
101  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
102 
104  itkSetClampMacro(NumberOfHistogramBins, SizeValueType, 1, NumericTraits<SizeValueType>::max());
105  itkGetConstMacro(NumberOfHistogramBins, SizeValueType);
107 
109  itkSetClampMacro(NumberOfThresholds, SizeValueType, 1, NumericTraits<SizeValueType>::max());
110  itkGetConstMacro(NumberOfThresholds, SizeValueType);
112 
114  itkSetClampMacro(LabelOffset,
118  itkGetConstMacro(LabelOffset, OutputPixelType);
120 
122  itkSetMacro(ValleyEmphasis, bool);
123  itkGetConstReferenceMacro(ValleyEmphasis, bool);
124  itkBooleanMacro(ValleyEmphasis);
126 
129  itkSetMacro(ReturnBinMidpoint, bool);
130  itkGetConstReferenceMacro(ReturnBinMidpoint, bool);
131  itkBooleanMacro(ReturnBinMidpoint);
133 
135  const ThresholdVectorType &
137  {
138  return m_Thresholds;
139  }
140 
141 #ifdef ITK_USE_CONCEPT_CHECKING
142  // Begin concept checking
143  itkConceptMacro(OutputComparableCheck, (Concept::Comparable<OutputPixelType>));
144  itkConceptMacro(OutputOStreamWritableCheck, (Concept::OStreamWritable<OutputPixelType>));
145  // End concept checking
146 #endif
147 
148 protected:
150  ~OtsuMultipleThresholdsImageFilter() override = default;
151  void
152  PrintSelf(std::ostream & os, Indent indent) const override;
153 
154  void
155  GenerateInputRequestedRegion() override;
156 
157  void
158  GenerateData() override;
159 
160 private:
161  SizeValueType m_NumberOfHistogramBins{ 128 };
162  SizeValueType m_NumberOfThresholds{ 1 };
165  bool m_ValleyEmphasis{ false };
166 #if defined(ITKV4_COMPATIBILITY)
167  bool m_ReturnBinMidpoint{ true };
168 #else
169  bool m_ReturnBinMidpoint{ false };
170 #endif
171 };
172 } // end namespace itk
173 
174 #ifndef ITK_MANUAL_INSTANTIATION
175 # include "itkOtsuMultipleThresholdsImageFilter.hxx"
176 #endif
177 
178 #endif
itk::OtsuMultipleThresholdsImageFilter::GetThresholds
const ThresholdVectorType & GetThresholds() const
Definition: itkOtsuMultipleThresholdsImageFilter.h:136
itk::Concept::OStreamWritable
Definition: itkConceptChecking.h:636
itk::OtsuMultipleThresholdsImageFilter::OutputIndexType
typename TOutputImage::IndexType OutputIndexType
Definition: itkOtsuMultipleThresholdsImageFilter.h:90
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::OtsuMultipleThresholdsImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkOtsuMultipleThresholdsImageFilter.h:80
itk::Statistics::ScalarImageToHistogramGenerator
TODO.
Definition: itkScalarImageToHistogramGenerator.h:37
itk::OtsuMultipleThresholdsImageFilter::m_Thresholds
ThresholdVectorType m_Thresholds
Definition: itkOtsuMultipleThresholdsImageFilter.h:164
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::OtsuMultipleThresholdsImageFilter
Threshold an image using multiple Otsu Thresholds.
Definition: itkOtsuMultipleThresholdsImageFilter.h:61
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itkOtsuMultipleThresholdsCalculator.h
itk::OtsuMultipleThresholdsCalculator::OutputType
std::vector< MeasurementType > OutputType
Definition: itkOtsuMultipleThresholdsCalculator.h:79
itkScalarImageToHistogramGenerator.h
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::Statistics::Histogram
This class stores measurement vectors in the context of n-dimensional histogram.
Definition: itkHistogram.h:77
itk::ImageToImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageToImageFilter.h:130
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itkFixedArray.h
itk::OtsuMultipleThresholdsImageFilter::OutputSizeType
typename TOutputImage::SizeType OutputSizeType
Definition: itkOtsuMultipleThresholdsImageFilter.h:89
itkImageToImageFilter.h
itk::OtsuMultipleThresholdsImageFilter::m_LabelOffset
OutputPixelType m_LabelOffset
Definition: itkOtsuMultipleThresholdsImageFilter.h:163
itk::OtsuMultipleThresholdsImageFilter::ThresholdVectorType
typename OtsuCalculatorType::OutputType ThresholdVectorType
Definition: itkOtsuMultipleThresholdsImageFilter.h:97
itk::Concept::Comparable
Definition: itkConceptChecking.h:330
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::OtsuMultipleThresholdsImageFilter::HistogramType
typename HistogramGeneratorType::HistogramType HistogramType
Definition: itkOtsuMultipleThresholdsImageFilter.h:95
itk::OtsuMultipleThresholdsImageFilter::InputIndexType
typename TInputImage::IndexType InputIndexType
Definition: itkOtsuMultipleThresholdsImageFilter.h:87
itk::OtsuMultipleThresholdsImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkOtsuMultipleThresholdsImageFilter.h:79
itk::ImageToImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkImageToImageFilter.h:132
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::OtsuMultipleThresholdsCalculator
Computes Otsu's multiple thresholds for a histogram.
Definition: itkOtsuMultipleThresholdsCalculator.h:50
itk::OtsuMultipleThresholdsImageFilter::InputSizeType
typename TInputImage::SizeType InputSizeType
Definition: itkOtsuMultipleThresholdsImageFilter.h:86