ITK  5.2.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 
61 template <typename TInputImage, typename TOutputImage, typename TMaskImage = TOutputImage>
62 class ITK_TEMPLATE_EXPORT HistogramThresholdImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
63 {
64 public:
65  ITK_DISALLOW_COPY_AND_MOVE(HistogramThresholdImageFilter);
66 
72 
74  itkNewMacro(Self);
75 
78 
79  using InputImageType = TInputImage;
80  using OutputImageType = TOutputImage;
81  using MaskImageType = TMaskImage;
82 
84  using InputPixelType = typename InputImageType::PixelType;
85  using OutputPixelType = typename OutputImageType::PixelType;
86  using MaskPixelType = typename MaskImageType::PixelType;
87 
89  using InputImagePointer = typename InputImageType::Pointer;
90  using OutputImagePointer = typename OutputImageType::Pointer;
91  using MaskImagePointer = typename MaskImageType::Pointer;
92 
102 
113 
116 
118  static constexpr unsigned int InputImageDimension = InputImageType::ImageDimension;
119  static constexpr unsigned int OutputImageDimension = OutputImageType::ImageDimension;
120  static constexpr unsigned int MaskImageDimension = MaskImageType::ImageDimension;
121 
123  itkSetInputMacro(MaskImage, TMaskImage);
124  itkGetInputMacro(MaskImage, TMaskImage);
126 
128  void
129  SetInput1(const TInputImage * input)
130  {
131  this->SetInput(input);
132  }
133 
135  void
136  SetInput2(const TMaskImage * input)
137  {
138  this->SetMaskImage(input);
139  }
140 
143  itkSetMacro(OutsideValue, OutputPixelType);
144 
146  itkGetConstMacro(OutsideValue, OutputPixelType);
147 
150  itkSetMacro(InsideValue, OutputPixelType);
151 
153  itkGetConstMacro(InsideValue, OutputPixelType);
154 
156  itkSetMacro(NumberOfHistogramBins, unsigned int);
157  itkGetConstMacro(NumberOfHistogramBins, unsigned int);
159 
162  itkSetMacro(AutoMinimumMaximum, bool);
163  itkGetConstMacro(AutoMinimumMaximum, bool);
164  itkBooleanMacro(AutoMinimumMaximum);
166 
170  itkSetMacro(MaskOutput, bool);
171  itkGetConstMacro(MaskOutput, bool);
172  itkBooleanMacro(MaskOutput);
174 
178  itkSetMacro(MaskValue, MaskPixelType);
179  itkGetConstMacro(MaskValue, MaskPixelType);
181 
183  itkGetConstMacro(Threshold, InputPixelType);
184 
186  itkSetObjectMacro(Calculator, CalculatorType);
187  itkGetModifiableObjectMacro(Calculator, CalculatorType);
189 
190 #ifdef ITK_USE_CONCEPT_CHECKING
191  // Begin concept checking
192  itkConceptMacro(OutputEqualityComparableCheck, (Concept::EqualityComparable<OutputPixelType>));
193  itkConceptMacro(InputOStreamWritableCheck, (Concept::OStreamWritable<InputPixelType>));
194  itkConceptMacro(OutputOStreamWritableCheck, (Concept::OStreamWritable<OutputPixelType>));
195  // End concept checking
196 #endif
197 
198 protected:
200  ~HistogramThresholdImageFilter() override = default;
201  void
202  PrintSelf(std::ostream & os, Indent indent) const override;
203 
204  void
205  GenerateInputRequestedRegion() override;
206  void
207  GenerateData() override;
208 
209  void
210  VerifyPreconditions() ITKv5_CONST override
211  {
212  Superclass::VerifyPreconditions();
213  if (m_Calculator.IsNull())
214  {
215  itkExceptionMacro(<< "No threshold calculator set.");
216  }
217  }
218 
219 private:
221  void
222  SetUpHistogramGenerator(HistogramGeneratorPointer histogramGenerator);
223 
229  unsigned m_NumberOfHistogramBins{ 256 };
231  bool m_MaskOutput{ true };
232 };
233 
234 } // end namespace itk
235 
236 #ifndef ITK_MANUAL_INSTANTIATION
237 # include "itkHistogramThresholdImageFilter.hxx"
238 #endif
239 
240 #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::Concept::OStreamWritable
Definition: itkConceptChecking.h:636
itkImageToHistogramFilter.h
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::HistogramThresholdImageFilter::SetInput1
void SetInput1(const TInputImage *input)
Definition: itkHistogramThresholdImageFilter.h:129
itk::HistogramThresholdImageFilter::InputPixelType
typename InputImageType::PixelType InputPixelType
Definition: itkHistogramThresholdImageFilter.h:84
itk::HistogramThresholdImageFilter::HistogramSizeType
typename HistogramType::SizeType HistogramSizeType
Definition: itkHistogramThresholdImageFilter.h:108
itk::HistogramThresholdImageFilter::HistogramPointer
typename HistogramType::Pointer HistogramPointer
Definition: itkHistogramThresholdImageFilter.h:106
itk::HistogramThresholdImageFilter::MaskImageRegionType
typename MaskImageType::RegionType MaskImageRegionType
Definition: itkHistogramThresholdImageFilter.h:101
itk::HistogramThresholdImageFilter::MaskSizeType
typename MaskImageType::SizeType MaskSizeType
Definition: itkHistogramThresholdImageFilter.h:99
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
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:107
itk::HistogramThresholdImageFilter::m_Calculator
CalculatorPointer m_Calculator
Definition: itkHistogramThresholdImageFilter.h:228
itk::HistogramThresholdImageFilter::OutputIndexType
typename OutputImageType::IndexType OutputIndexType
Definition: itkHistogramThresholdImageFilter.h:97
itk::HistogramThresholdImageFilter::m_MaskValue
MaskPixelType m_MaskValue
Definition: itkHistogramThresholdImageFilter.h:227
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:224
itkHistogram.h
itk::ImageToImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageToImageFilter.h:130
itk::HistogramThresholdImageFilter::HistogramGeneratorPointer
typename HistogramGeneratorType::Pointer HistogramGeneratorPointer
Definition: itkHistogramThresholdImageFilter.h:115
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
itkImageToImageFilter.h
itk::HistogramThresholdImageFilter::InputSizeType
typename InputImageType::SizeType InputSizeType
Definition: itkHistogramThresholdImageFilter.h:93
itk::HistogramThresholdImageFilter::HistogramMeasurementType
typename HistogramType::MeasurementType HistogramMeasurementType
Definition: itkHistogramThresholdImageFilter.h:109
itk::HistogramThresholdImageFilter::MaskImageType
TMaskImage MaskImageType
Definition: itkHistogramThresholdImageFilter.h:81
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:46
itk::HistogramThresholdImageFilter::HistogramMeasurementVectorType
typename HistogramType::MeasurementVectorType HistogramMeasurementVectorType
Definition: itkHistogramThresholdImageFilter.h:110
itk::HistogramThresholdImageFilter::ValueRealType
typename NumericTraits< ValueType >::RealType ValueRealType
Definition: itkHistogramThresholdImageFilter.h:104
itk::HistogramThresholdImageFilter::SetInput2
void SetInput2(const TMaskImage *input)
Definition: itkHistogramThresholdImageFilter.h:136
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::HistogramThresholdImageFilter::CalculatorPointer
typename CalculatorType::Pointer CalculatorPointer
Definition: itkHistogramThresholdImageFilter.h:112
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk::HistogramThresholdImageFilter::MaskIndexType
typename MaskImageType::IndexType MaskIndexType
Definition: itkHistogramThresholdImageFilter.h:100
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::HistogramThresholdImageFilter::m_Threshold
InputPixelType m_Threshold
Definition: itkHistogramThresholdImageFilter.h:226
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:103
itk::HistogramThresholdImageFilter::m_OutsideValue
OutputPixelType m_OutsideValue
Definition: itkHistogramThresholdImageFilter.h:225
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:91
itk::Concept::EqualityComparable
Definition: itkConceptChecking.h:306
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::HistogramThresholdImageFilter::m_AutoMinimumMaximum
bool m_AutoMinimumMaximum
Definition: itkHistogramThresholdImageFilter.h:230