ITK  4.12.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:
70 
72  itkNewMacro(Self);
73 
76 
77  typedef TInputImage InputImageType;
78  typedef TOutputImage OutputImageType;
79  typedef TMaskImage MaskImageType;
80 
82  typedef typename InputImageType::PixelType InputPixelType;
83  typedef typename OutputImageType::PixelType OutputPixelType;
84  typedef typename MaskImageType::PixelType MaskPixelType;
85 
90 
91  typedef typename InputImageType::SizeType InputSizeType;
92  typedef typename InputImageType::IndexType InputIndexType;
93  typedef typename InputImageType::RegionType InputImageRegionType;
94  typedef typename OutputImageType::SizeType OutputSizeType;
95  typedef typename OutputImageType::IndexType OutputIndexType;
96  typedef typename OutputImageType::RegionType OutputImageRegionType;
97  typedef typename MaskImageType::SizeType MaskSizeType;
98  typedef typename MaskImageType::IndexType MaskIndexType;
99  typedef typename MaskImageType::RegionType MaskImageRegionType;
100 
112 
114  itkStaticConstMacro(InputImageDimension, unsigned int,
115  InputImageType::ImageDimension );
116  itkStaticConstMacro(OutputImageDimension, unsigned int,
117  OutputImageType::ImageDimension );
118  itkStaticConstMacro(MaskImageDimension, unsigned int,
119  MaskImageType::ImageDimension );
121 
125  void SetMaskImage(const TMaskImage *input)
126  {
127  // Process object is not const-correct so the const casting is required.
128  this->SetNthInput( 1, const_cast< TMaskImage * >( input ) );
129  }
130 
132  const MaskImageType * GetMaskImage() const
133  {
134  return itkDynamicCastInDebugMode< MaskImageType * >
135  (const_cast< DataObject * >( this->ProcessObject::GetInput(1) ) );
136  }
137 
139  void SetInput1(const TInputImage *input)
140  {
141  this->SetInput(input);
142  }
143 
145  void SetInput2(const TMaskImage *input)
146  {
147  this->SetMaskImage(input);
148  }
149 
152  itkSetMacro(OutsideValue, OutputPixelType);
153 
155  itkGetConstMacro(OutsideValue, OutputPixelType);
156 
159  itkSetMacro(InsideValue, OutputPixelType);
160 
162  itkGetConstMacro(InsideValue, OutputPixelType);
163 
165  itkSetMacro(NumberOfHistogramBins, unsigned int);
166  itkGetConstMacro(NumberOfHistogramBins, unsigned int);
168 
171  itkSetMacro(AutoMinimumMaximum, bool);
172  itkGetConstMacro(AutoMinimumMaximum, bool);
173  itkBooleanMacro(AutoMinimumMaximum);
175 
179  itkSetMacro(MaskOutput, bool);
180  itkGetConstMacro(MaskOutput, bool);
181  itkBooleanMacro(MaskOutput);
183 
187  itkSetMacro(MaskValue, MaskPixelType);
188  itkGetConstMacro(MaskValue, MaskPixelType);
190 
192  itkGetConstMacro(Threshold, InputPixelType);
193 
195  itkSetObjectMacro(Calculator, CalculatorType);
196  itkGetModifiableObjectMacro(Calculator, CalculatorType);
198 
199 #ifdef ITK_USE_CONCEPT_CHECKING
200  // Begin concept checking
201  itkConceptMacro(OutputEqualityComparableCheck,
203  itkConceptMacro(InputOStreamWritableCheck,
205  itkConceptMacro(OutputOStreamWritableCheck,
207  // End concept checking
208 #endif
209 
210 protected:
213  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
214 
215  void GenerateInputRequestedRegion() ITK_OVERRIDE;
216  void GenerateData () ITK_OVERRIDE;
217 
218 private:
219  ITK_DISALLOW_COPY_AND_ASSIGN(HistogramThresholdImageFilter);
220 
221  OutputPixelType m_InsideValue;
223  InputPixelType m_Threshold;
224  MaskPixelType m_MaskValue;
225  CalculatorPointer m_Calculator;
226  unsigned m_NumberOfHistogramBins;
227  bool m_AutoMinimumMaximum;
228  bool m_MaskOutput;
229 };
230 
231 } // end namespace itk
232 
233 #ifndef ITK_MANUAL_INSTANTIATION
234 #include "itkHistogramThresholdImageFilter.hxx"
235 #endif
236 
237 #endif
Threshold an image using a HistogramThresholdCalculator.
virtual void PrintSelf(std::ostream &os, Indent indent) const override
Statistics::Histogram< ValueRealType > HistogramType
NumericTraits< InputPixelType >::ValueType ValueType
This class stores measurement vectors in the context of n-dimensional histogram.
Definition: itkHistogram.h:77
HistogramThresholdCalculator< HistogramType, InputPixelType > CalculatorType
Base class for all process objects that output image data.
SmartPointer< Self > Pointer
HistogramType::MeasurementVectorType HistogramMeasurementVectorType
NumericTraits< ValueType >::RealType ValueRealType
HistogramType::MeasurementType HistogramMeasurementType
Superclass::MeasurementVectorType MeasurementVectorType
Definition: itkHistogram.h:101
TMeasurement MeasurementType
Definition: itkHistogram.h:95
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Base class for all data objects in ITK.
TOutput m_OutsideValue
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
Define additional traits for native types such as int or float.
Base class to compute a threshold value based on the histogram of an image.
#define itkConceptMacro(name, concept)
ImageToImageFilter< TInputImage, TOutputImage > Superclass