ITK  5.1.0
Insight Toolkit
itkHistogramThresholdImageFilter.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 itkHistogramThresholdImageFilter_h
20 #define itkHistogramThresholdImageFilter_h
21 
22 #include "itkImageToImageFilter.h"
24 #include "itkHistogram.h"
26 
27 namespace itk
28 {
29 
62 template <typename TInputImage, typename TOutputImage, typename TMaskImage = TOutputImage>
63 class ITK_TEMPLATE_EXPORT HistogramThresholdImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
64 {
65 public:
66  ITK_DISALLOW_COPY_AND_ASSIGN(HistogramThresholdImageFilter);
67 
73 
75  itkNewMacro(Self);
76 
79 
80  using InputImageType = TInputImage;
81  using OutputImageType = TOutputImage;
82  using MaskImageType = TMaskImage;
83 
85  using InputPixelType = typename InputImageType::PixelType;
86  using OutputPixelType = typename OutputImageType::PixelType;
87  using MaskPixelType = typename MaskImageType::PixelType;
88 
90  using InputImagePointer = typename InputImageType::Pointer;
91  using OutputImagePointer = typename OutputImageType::Pointer;
92  using MaskImagePointer = typename MaskImageType::Pointer;
93 
103 
114 
117 
119  static constexpr unsigned int InputImageDimension = InputImageType::ImageDimension;
120  static constexpr unsigned int OutputImageDimension = OutputImageType::ImageDimension;
121  static constexpr unsigned int MaskImageDimension = MaskImageType::ImageDimension;
122 
124  itkSetInputMacro(MaskImage, TMaskImage);
125  itkGetInputMacro(MaskImage, TMaskImage);
127 
129  void
130  SetInput1(const TInputImage * input)
131  {
132  this->SetInput(input);
133  }
134 
136  void
137  SetInput2(const TMaskImage * input)
138  {
139  this->SetMaskImage(input);
140  }
141 
144  itkSetMacro(OutsideValue, OutputPixelType);
145 
147  itkGetConstMacro(OutsideValue, OutputPixelType);
148 
151  itkSetMacro(InsideValue, OutputPixelType);
152 
154  itkGetConstMacro(InsideValue, OutputPixelType);
155 
157  itkSetMacro(NumberOfHistogramBins, unsigned int);
158  itkGetConstMacro(NumberOfHistogramBins, unsigned int);
160 
163  itkSetMacro(AutoMinimumMaximum, bool);
164  itkGetConstMacro(AutoMinimumMaximum, bool);
165  itkBooleanMacro(AutoMinimumMaximum);
167 
171  itkSetMacro(MaskOutput, bool);
172  itkGetConstMacro(MaskOutput, bool);
173  itkBooleanMacro(MaskOutput);
175 
179  itkSetMacro(MaskValue, MaskPixelType);
180  itkGetConstMacro(MaskValue, MaskPixelType);
182 
184  itkGetConstMacro(Threshold, InputPixelType);
185 
187  itkSetObjectMacro(Calculator, CalculatorType);
188  itkGetModifiableObjectMacro(Calculator, CalculatorType);
190 
191 #ifdef ITK_USE_CONCEPT_CHECKING
192  // Begin concept checking
193  itkConceptMacro(OutputEqualityComparableCheck, (Concept::EqualityComparable<OutputPixelType>));
194  itkConceptMacro(InputOStreamWritableCheck, (Concept::OStreamWritable<InputPixelType>));
195  itkConceptMacro(OutputOStreamWritableCheck, (Concept::OStreamWritable<OutputPixelType>));
196  // End concept checking
197 #endif
198 
199 protected:
201  ~HistogramThresholdImageFilter() override = default;
202  void
203  PrintSelf(std::ostream & os, Indent indent) const override;
204 
205  void
206  GenerateInputRequestedRegion() override;
207  void
208  GenerateData() override;
209 
211  void
212  SetUpHistogramGenerator(HistogramGeneratorPointer histogramGenerator);
213 
214  void
215  VerifyPreconditions() ITKv5_CONST override
216  {
217  Superclass::VerifyPreconditions();
218  if (m_Calculator.IsNull())
219  {
220  itkExceptionMacro(<< "No threshold calculator set.");
221  }
222  }
223 
224 private:
230  unsigned m_NumberOfHistogramBins{ 256 };
232  bool m_MaskOutput{ true };
233 };
234 
235 } // end namespace itk
236 
237 #ifndef ITK_MANUAL_INSTANTIATION
238 # include "itkHistogramThresholdImageFilter.hxx"
239 #endif
240 
241 #endif
itk::HistogramThresholdImageFilter::VerifyPreconditions
void VerifyPreconditions() ITKv5_CONST override
Definition: itkHistogramThresholdImageFilter.h:215
itk::HistogramThresholdImageFilter::InputIndexType
typename InputImageType::IndexType InputIndexType
Definition: itkHistogramThresholdImageFilter.h:95
itk::Concept::OStreamWritable
Definition: itkConceptChecking.h:634
itkImageToHistogramFilter.h
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::HistogramThresholdImageFilter::SetInput1
void SetInput1(const TInputImage *input)
Definition: itkHistogramThresholdImageFilter.h:130
itk::HistogramThresholdImageFilter::InputPixelType
typename InputImageType::PixelType InputPixelType
Definition: itkHistogramThresholdImageFilter.h:85
itk::HistogramThresholdImageFilter::HistogramSizeType
typename HistogramType::SizeType HistogramSizeType
Definition: itkHistogramThresholdImageFilter.h:109
itk::HistogramThresholdImageFilter::HistogramPointer
typename HistogramType::Pointer HistogramPointer
Definition: itkHistogramThresholdImageFilter.h:107
itk::HistogramThresholdImageFilter::MaskImageRegionType
typename MaskImageType::RegionType MaskImageRegionType
Definition: itkHistogramThresholdImageFilter.h:102
itk::HistogramThresholdImageFilter::MaskSizeType
typename MaskImageType::SizeType MaskSizeType
Definition: itkHistogramThresholdImageFilter.h:100
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::HistogramThresholdImageFilter::OutputSizeType
typename OutputImageType::SizeType OutputSizeType
Definition: itkHistogramThresholdImageFilter.h:97
itk::HistogramThresholdImageFilter
Threshold an image using a HistogramThresholdCalculator.
Definition: itkHistogramThresholdImageFilter.h:63
itk::HistogramThresholdImageFilter::OutputPixelType
typename OutputImageType::PixelType OutputPixelType
Definition: itkHistogramThresholdImageFilter.h:86
itkHistogramThresholdCalculator.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::HistogramThresholdImageFilter::HistogramConstPointer
typename HistogramType::ConstPointer HistogramConstPointer
Definition: itkHistogramThresholdImageFilter.h:108
itk::HistogramThresholdImageFilter::m_Calculator
CalculatorPointer m_Calculator
Definition: itkHistogramThresholdImageFilter.h:229
itk::HistogramThresholdImageFilter::OutputIndexType
typename OutputImageType::IndexType OutputIndexType
Definition: itkHistogramThresholdImageFilter.h:98
itk::HistogramThresholdImageFilter::m_MaskValue
MaskPixelType m_MaskValue
Definition: itkHistogramThresholdImageFilter.h:228
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::MeasurementVectorType
typename Superclass::MeasurementVectorType MeasurementVectorType
Definition: itkHistogram.h:101
itk::Statistics::Histogram
This class stores measurement vectors in the context of n-dimensional histogram.
Definition: itkHistogram.h:77
itk::HistogramThresholdImageFilter::m_InsideValue
OutputPixelType m_InsideValue
Definition: itkHistogramThresholdImageFilter.h:225
itkHistogram.h
itk::ImageToImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageToImageFilter.h:130
itk::HistogramThresholdImageFilter::HistogramGeneratorPointer
typename HistogramGeneratorType::Pointer HistogramGeneratorPointer
Definition: itkHistogramThresholdImageFilter.h:116
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::HistogramThresholdImageFilter::MaskPixelType
typename MaskImageType::PixelType MaskPixelType
Definition: itkHistogramThresholdImageFilter.h:87
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itkImageToImageFilter.h
itk::HistogramThresholdImageFilter::InputSizeType
typename InputImageType::SizeType InputSizeType
Definition: itkHistogramThresholdImageFilter.h:94
itk::HistogramThresholdImageFilter::HistogramMeasurementType
typename HistogramType::MeasurementType HistogramMeasurementType
Definition: itkHistogramThresholdImageFilter.h:110
itk::HistogramThresholdImageFilter::MaskImageType
TMaskImage MaskImageType
Definition: itkHistogramThresholdImageFilter.h:82
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::HistogramThresholdCalculator
Base class to compute a threshold value based on the histogram of an image.
Definition: itkHistogramThresholdCalculator.h:47
itk::HistogramThresholdImageFilter::HistogramMeasurementVectorType
typename HistogramType::MeasurementVectorType HistogramMeasurementVectorType
Definition: itkHistogramThresholdImageFilter.h:111
itk::HistogramThresholdImageFilter::ValueRealType
typename NumericTraits< ValueType >::RealType ValueRealType
Definition: itkHistogramThresholdImageFilter.h:105
itk::HistogramThresholdImageFilter::SetInput2
void SetInput2(const TMaskImage *input)
Definition: itkHistogramThresholdImageFilter.h:137
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::HistogramThresholdImageFilter::CalculatorPointer
typename CalculatorType::Pointer CalculatorPointer
Definition: itkHistogramThresholdImageFilter.h:113
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:64
itk::HistogramThresholdImageFilter::MaskIndexType
typename MaskImageType::IndexType MaskIndexType
Definition: itkHistogramThresholdImageFilter.h:101
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::HistogramThresholdImageFilter::m_Threshold
InputPixelType m_Threshold
Definition: itkHistogramThresholdImageFilter.h:227
itk::NumericTraits::RealType
double RealType
Definition: itkNumericTraits.h:84
itk::Statistics::ImageToHistogramFilter
This class generates a histogram from an image.
Definition: itkImageToHistogramFilter.h:50
itk::HistogramThresholdImageFilter::ValueType
typename NumericTraits< InputPixelType >::ValueType ValueType
Definition: itkHistogramThresholdImageFilter.h:104
itk::HistogramThresholdImageFilter::m_OutsideValue
OutputPixelType m_OutsideValue
Definition: itkHistogramThresholdImageFilter.h:226
itk::Statistics::Histogram::MeasurementType
TMeasurement MeasurementType
Definition: itkHistogram.h:98
itk::ImageToImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkImageToImageFilter.h:132
itk::HistogramThresholdImageFilter::MaskImagePointer
typename MaskImageType::Pointer MaskImagePointer
Definition: itkHistogramThresholdImageFilter.h:92
itk::Concept::EqualityComparable
Definition: itkConceptChecking.h:304
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::HistogramThresholdImageFilter::m_AutoMinimumMaximum
bool m_AutoMinimumMaximum
Definition: itkHistogramThresholdImageFilter.h:231