ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkHistogramThresholdImageFilter.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 itkHistogramThresholdImageFilter_h
20 #define itkHistogramThresholdImageFilter_h
21 
22 #include "itkImageToImageFilter.h"
23 #include "itkHistogram.h"
25 
26 namespace itk
27 {
28 
60 template<typename TInputImage, typename TOutputImage, typename TMaskImage=TOutputImage>
61 class ITK_TEMPLATE_EXPORT HistogramThresholdImageFilter :
62  public ImageToImageFilter<TInputImage, TOutputImage>
63 {
64 public:
65  ITK_DISALLOW_COPY_AND_ASSIGN(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 
111  using CalculatorType =
114 
116  static constexpr unsigned int InputImageDimension = InputImageType::ImageDimension;
117  static constexpr unsigned int OutputImageDimension = OutputImageType::ImageDimension;
118  static constexpr unsigned int MaskImageDimension = MaskImageType::ImageDimension;
119 
121  itkSetInputMacro(MaskImage, TMaskImage);
122  itkGetInputMacro(MaskImage, TMaskImage);
124 
126  void SetInput1(const TInputImage *input)
127  {
128  this->SetInput(input);
129  }
130 
132  void SetInput2(const TMaskImage *input)
133  {
134  this->SetMaskImage(input);
135  }
136 
139  itkSetMacro(OutsideValue, OutputPixelType);
140 
142  itkGetConstMacro(OutsideValue, OutputPixelType);
143 
146  itkSetMacro(InsideValue, OutputPixelType);
147 
149  itkGetConstMacro(InsideValue, OutputPixelType);
150 
152  itkSetMacro(NumberOfHistogramBins, unsigned int);
153  itkGetConstMacro(NumberOfHistogramBins, unsigned int);
155 
158  itkSetMacro(AutoMinimumMaximum, bool);
159  itkGetConstMacro(AutoMinimumMaximum, bool);
160  itkBooleanMacro(AutoMinimumMaximum);
162 
166  itkSetMacro(MaskOutput, bool);
167  itkGetConstMacro(MaskOutput, bool);
168  itkBooleanMacro(MaskOutput);
170 
174  itkSetMacro(MaskValue, MaskPixelType);
175  itkGetConstMacro(MaskValue, MaskPixelType);
177 
179  itkGetConstMacro(Threshold, InputPixelType);
180 
182  itkSetObjectMacro(Calculator, CalculatorType);
183  itkGetModifiableObjectMacro(Calculator, CalculatorType);
185 
186 #ifdef ITK_USE_CONCEPT_CHECKING
187  // Begin concept checking
188  itkConceptMacro(OutputEqualityComparableCheck,
190  itkConceptMacro(InputOStreamWritableCheck,
192  itkConceptMacro(OutputOStreamWritableCheck,
194  // End concept checking
195 #endif
196 
197 protected:
199  ~HistogramThresholdImageFilter() override = default;
200  void PrintSelf(std::ostream& os, Indent indent) const override;
201 
202  void GenerateInputRequestedRegion() override;
203  void GenerateData () override;
204 
205 private:
211  unsigned m_NumberOfHistogramBins{ 256 };
213  bool m_MaskOutput{ true };
214 };
215 
216 } // end namespace itk
217 
218 #ifndef ITK_MANUAL_INSTANTIATION
219 #include "itkHistogramThresholdImageFilter.hxx"
220 #endif
221 
222 #endif
Threshold an image using a HistogramThresholdCalculator.
typename HistogramType::SizeType HistogramSizeType
typename OutputImageType::Pointer OutputImagePointer
typename NumericTraits< ValueType >::RealType ValueRealType
typename CalculatorType::Pointer CalculatorPointer
Define numeric traits for std::vector.
typename MaskImageType::SizeType MaskSizeType
This class stores measurement vectors in the context of n-dimensional histogram.
Definition: itkHistogram.h:77
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
typename MaskImageType::PixelType MaskPixelType
typename InputImageType::SizeType InputSizeType
typename NumericTraits< InputPixelType >::ValueType ValueType
Base class for all process objects that output image data.
typename HistogramType::MeasurementType HistogramMeasurementType
TMeasurement MeasurementType
Definition: itkHistogram.h:99
typename HistogramType::MeasurementVectorType HistogramMeasurementVectorType
typename InputImageType::Pointer InputImagePointer
typename OutputImageType::RegionType OutputImageRegionType
typename OutputImageType::SizeType OutputSizeType
typename HistogramType::ConstPointer HistogramConstPointer
TOutputImage OutputImageType
typename MaskImageType::RegionType MaskImageRegionType
typename InputImageType::IndexType InputIndexType
typename MaskImageType::IndexType MaskIndexType
typename InputImageType::RegionType InputImageRegionType
typename MaskImageType::Pointer MaskImagePointer
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename Superclass::MeasurementVectorType MeasurementVectorType
Definition: itkHistogram.h:102
Base class to compute a threshold value based on the histogram of an image.
typename OutputImageType::PixelType OutputPixelType
typename OutputImageType::IndexType OutputIndexType
typename HistogramType::Pointer HistogramPointer
#define itkConceptMacro(name, concept)
typename InputImageType::PixelType InputPixelType