ITK  5.2.0
Insight Toolkit
itkIntermodesThresholdImageFilter.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 
19 #ifndef itkIntermodesThresholdImageFilter_h
20 #define itkIntermodesThresholdImageFilter_h
21 
24 
25 namespace itk
26 {
27 
51 template <typename TInputImage, typename TOutputImage, typename TMaskImage = TOutputImage>
52 class IntermodesThresholdImageFilter : public HistogramThresholdImageFilter<TInputImage, TOutputImage, TMaskImage>
53 {
54 public:
55  ITK_DISALLOW_COPY_AND_MOVE(IntermodesThresholdImageFilter);
56 
62 
64  itkNewMacro(Self);
65 
68 
69  using InputImageType = TInputImage;
70  using OutputImageType = TOutputImage;
71  using MaskImageType = TMaskImage;
72 
74  using InputPixelType = typename InputImageType::PixelType;
75  using OutputPixelType = typename OutputImageType::PixelType;
76  using MaskPixelType = typename MaskImageType::PixelType;
77 
79  using InputImagePointer = typename InputImageType::Pointer;
80  using OutputImagePointer = typename OutputImageType::Pointer;
81 
91 
94 
95 
96  itkSetMacro(MaximumSmoothingIterations, SizeValueType);
97  itkGetMacro(MaximumSmoothingIterations, SizeValueType);
98 
101  itkSetMacro(UseInterMode, bool);
102  itkGetConstReferenceMacro(UseInterMode, bool);
103  itkBooleanMacro(UseInterMode);
105 
107  static constexpr unsigned int InputImageDimension = InputImageType::ImageDimension;
108  static constexpr unsigned int OutputImageDimension = OutputImageType::ImageDimension;
109 
110 protected:
112  {
113  auto calculator = CalculatorType::New();
114  calculator->SetMaximumSmoothingIterations(m_MaximumSmoothingIterations);
115  calculator->SetUseInterMode(m_UseInterMode);
116  Superclass::SetCalculator(calculator);
117  }
118  ~IntermodesThresholdImageFilter() override = default;
119 
120  void
121  VerifyPreconditions() ITKv5_CONST override
122  {
124  if (dynamic_cast<const CalculatorType *>(Superclass::GetCalculator()) == nullptr)
125  {
126  itkExceptionMacro(<< "Invalid IntermodesCalculator.");
127  }
128  }
129 
130  void
131  GenerateData() override
132  {
133  auto calculator = static_cast<CalculatorType *>(this->Superclass::GetModifiableCalculator());
134  calculator->SetMaximumSmoothingIterations(m_MaximumSmoothingIterations);
135  calculator->SetUseInterMode(m_UseInterMode);
136  this->Superclass::GenerateData();
137  }
138 
139 
140  void
141  PrintSelf(std::ostream & os, Indent indent) const override
142  {
143  Superclass::PrintSelf(os, indent);
144  os << indent << "MaximumSmoothingIterations: " << m_MaximumSmoothingIterations << std::endl;
145  os << indent << "UseInterMode: " << m_UseInterMode << std::endl;
146  }
147 
148 private:
150  bool m_UseInterMode{ true };
151 };
152 
153 } // end namespace itk
154 
155 #endif
itk::HistogramThresholdImageFilter::VerifyPreconditions
void VerifyPreconditions() ITKv5_CONST override
Definition: itkHistogramThresholdImageFilter.h:210
itk::HistogramThresholdImageFilter::InputIndexType
typename InputImageType::IndexType InputIndexType
Definition: itkHistogramThresholdImageFilter.h:94
itk::IntermodesThresholdImageFilter::GenerateData
void GenerateData() override
Definition: itkIntermodesThresholdImageFilter.h:131
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::HistogramThresholdImageFilter::HistogramType
Statistics::Histogram< ValueRealType > HistogramType
Definition: itkHistogramThresholdImageFilter.h:105
itk::HistogramThresholdImageFilter::InputPixelType
typename InputImageType::PixelType InputPixelType
Definition: itkHistogramThresholdImageFilter.h:84
itk::HistogramThresholdImageFilter::MaskImageRegionType
typename MaskImageType::RegionType MaskImageRegionType
Definition: itkHistogramThresholdImageFilter.h:101
itk::IntermodesThresholdImageFilter::OutputImageDimension
static constexpr unsigned int OutputImageDimension
Definition: itkIntermodesThresholdImageFilter.h:108
itk::HistogramThresholdImageFilter::MaskSizeType
typename MaskImageType::SizeType MaskSizeType
Definition: itkHistogramThresholdImageFilter.h:99
itk::IntermodesThresholdImageFilter::m_MaximumSmoothingIterations
SizeValueType m_MaximumSmoothingIterations
Definition: itkIntermodesThresholdImageFilter.h:149
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::HistogramThresholdImageFilter::OutputSizeType
typename OutputImageType::SizeType OutputSizeType
Definition: itkHistogramThresholdImageFilter.h:96
itk::HistogramThresholdImageFilter
Threshold an image using a HistogramThresholdCalculator.
Definition: itkHistogramThresholdImageFilter.h:62
itk::HistogramThresholdImageFilter::OutputPixelType
typename OutputImageType::PixelType OutputPixelType
Definition: itkHistogramThresholdImageFilter.h:85
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::IntermodesThresholdCalculator::New
static Pointer New()
itk::HistogramThresholdImageFilter::OutputIndexType
typename OutputImageType::IndexType OutputIndexType
Definition: itkHistogramThresholdImageFilter.h:97
itk::HistogramThresholdImageFilter::GetCalculator
virtual const CalculatorType * GetCalculator() const
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
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::IntermodesThresholdImageFilter
Threshold an image using the Intermodes Threshold.
Definition: itkIntermodesThresholdImageFilter.h:52
itk::HistogramThresholdImageFilter::GetModifiableCalculator
virtual CalculatorType * GetModifiableCalculator()
itk::ImageToImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageToImageFilter.h:130
itk::IntermodesThresholdImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkIntermodesThresholdImageFilter.h:141
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::HistogramThresholdImageFilter::MaskPixelType
typename MaskImageType::PixelType MaskPixelType
Definition: itkHistogramThresholdImageFilter.h:86
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::HistogramThresholdImageFilter::InputSizeType
typename InputImageType::SizeType InputSizeType
Definition: itkHistogramThresholdImageFilter.h:93
itk::HistogramThresholdImageFilter::MaskImageType
TMaskImage MaskImageType
Definition: itkHistogramThresholdImageFilter.h:81
itk::IntermodesThresholdImageFilter::IntermodesThresholdImageFilter
IntermodesThresholdImageFilter()
Definition: itkIntermodesThresholdImageFilter.h:111
itk::IntermodesThresholdImageFilter::m_UseInterMode
bool m_UseInterMode
Definition: itkIntermodesThresholdImageFilter.h:150
itk::HistogramThresholdCalculator
Base class to compute a threshold value based on the histogram of an image.
Definition: itkHistogramThresholdCalculator.h:46
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::HistogramThresholdImageFilter::SetCalculator
virtual void SetCalculator(CalculatorType *_arg)
itk::HistogramThresholdImageFilter::GenerateData
void GenerateData() override
itk::HistogramThresholdImageFilter::MaskIndexType
typename MaskImageType::IndexType MaskIndexType
Definition: itkHistogramThresholdImageFilter.h:100
itk::HistogramThresholdImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
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::IntermodesThresholdCalculator
Computes the Intermodes's threshold for an image.
Definition: itkIntermodesThresholdCalculator.h:56
itkHistogramThresholdImageFilter.h
itk::IntermodesThresholdImageFilter::VerifyPreconditions
void VerifyPreconditions() ITKv5_CONST override
Definition: itkIntermodesThresholdImageFilter.h:121
itk::IntermodesThresholdImageFilter::~IntermodesThresholdImageFilter
~IntermodesThresholdImageFilter() override=default
itk::IntermodesThresholdImageFilter::InputImageDimension
static constexpr unsigned int InputImageDimension
Definition: itkIntermodesThresholdImageFilter.h:107
itk::ImageToImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkImageToImageFilter.h:132
itkIntermodesThresholdCalculator.h
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90