ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkOtsuThresholdImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 
19 #ifndef itkOtsuThresholdImageFilter_h
20 #define itkOtsuThresholdImageFilter_h
21 
24 
25 namespace itk
26 {
27 
54 template<typename TInputImage, typename TOutputImage, typename TMaskImage=TOutputImage>
56  public HistogramThresholdImageFilter<TInputImage, TOutputImage, TMaskImage>
57 {
58 public:
59  ITK_DISALLOW_COPY_AND_ASSIGN(OtsuThresholdImageFilter);
60 
63  using Superclass = HistogramThresholdImageFilter<TInputImage,TOutputImage,
64  TMaskImage>;
67 
69  itkNewMacro(Self);
70 
73 
74  using InputImageType = TInputImage;
75  using OutputImageType = TOutputImage;
76  using MaskImageType = TMaskImage;
77 
79  using InputPixelType = typename InputImageType::PixelType;
80  using OutputPixelType = typename OutputImageType::PixelType;
81  using MaskPixelType = typename MaskImageType::PixelType;
82 
84  using InputImagePointer = typename InputImageType::Pointer;
85  using OutputImagePointer = typename OutputImageType::Pointer;
86 
96 
99 
101  static constexpr unsigned int InputImageDimension = InputImageType::ImageDimension;
102  static constexpr unsigned int OutputImageDimension = OutputImageType::ImageDimension;
103 
106  itkSetMacro(ReturnBinMidpoint, bool);
107  itkGetConstReferenceMacro(ReturnBinMidpoint, bool);
108  itkBooleanMacro(ReturnBinMidpoint);
110 
111 protected:
113 
114  {
116  }
117  ~OtsuThresholdImageFilter() override = default;
118 
119  void GenerateData() override
120  {
121  auto calc = static_cast<CalculatorType *>(this->GetModifiableCalculator());
122  calc->SetReturnBinMidpoint(m_ReturnBinMidpoint);
123  this->Superclass::GenerateData();
124  }
125 private:
126 
127 #if defined(ITKV4_COMPATIBILITY)
128  bool m_ReturnBinMidpoint{ true };
129 #else
130  bool m_ReturnBinMidpoint{ false };
131 #endif
132 };
133 
134 } // end namespace itk
135 
136 #endif
Threshold an image using a HistogramThresholdCalculator.
typename OutputImageType::Pointer OutputImagePointer
typename MaskImageType::SizeType MaskSizeType
static constexpr unsigned int InputImageDimension
static constexpr unsigned int OutputImageDimension
Computes the Otsu&#39;s threshold for an image.
This class stores measurement vectors in the context of n-dimensional histogram.
Definition: itkHistogram.h:77
virtual void SetCalculator(CalculatorType *_arg)
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
typename MaskImageType::PixelType MaskPixelType
typename InputImageType::SizeType InputSizeType
Base class for all process objects that output image data.
typename InputImageType::Pointer InputImagePointer
Threshold an image using the Otsu Threshold.
typename OutputImageType::RegionType OutputImageRegionType
typename OutputImageType::SizeType OutputSizeType
TOutputImage OutputImageType
typename MaskImageType::RegionType MaskImageRegionType
typename InputImageType::IndexType InputIndexType
typename MaskImageType::IndexType MaskIndexType
typename InputImageType::RegionType InputImageRegionType
Statistics::Histogram< ValueRealType > HistogramType
Base class to compute a threshold value based on the histogram of an image.
typename OutputImageType::PixelType OutputPixelType
typename OutputImageType::IndexType OutputIndexType
~OtsuThresholdImageFilter() override=default
virtual CalculatorType * GetModifiableCalculator()
typename InputImageType::PixelType InputPixelType