ITK  4.13.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 
87  typedef typename InputImageType::Pointer InputImagePointer;
88  typedef typename OutputImageType::Pointer OutputImagePointer;
89  typedef typename MaskImageType::Pointer MaskImagePointer;
90 
93  typedef typename InputImageType::RegionType InputImageRegionType;
96  typedef typename OutputImageType::RegionType OutputImageRegionType;
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 
123  itkSetInputMacro(MaskImage, TMaskImage);
124  itkGetInputMacro(MaskImage, TMaskImage);
126 
128  void SetInput1(const TInputImage *input)
129  {
130  this->SetInput(input);
131  }
132 
134  void SetInput2(const TMaskImage *input)
135  {
136  this->SetMaskImage(input);
137  }
138 
141  itkSetMacro(OutsideValue, OutputPixelType);
142 
144  itkGetConstMacro(OutsideValue, OutputPixelType);
145 
148  itkSetMacro(InsideValue, OutputPixelType);
149 
151  itkGetConstMacro(InsideValue, OutputPixelType);
152 
154  itkSetMacro(NumberOfHistogramBins, unsigned int);
155  itkGetConstMacro(NumberOfHistogramBins, unsigned int);
157 
160  itkSetMacro(AutoMinimumMaximum, bool);
161  itkGetConstMacro(AutoMinimumMaximum, bool);
162  itkBooleanMacro(AutoMinimumMaximum);
164 
168  itkSetMacro(MaskOutput, bool);
169  itkGetConstMacro(MaskOutput, bool);
170  itkBooleanMacro(MaskOutput);
172 
176  itkSetMacro(MaskValue, MaskPixelType);
177  itkGetConstMacro(MaskValue, MaskPixelType);
179 
181  itkGetConstMacro(Threshold, InputPixelType);
182 
184  itkSetObjectMacro(Calculator, CalculatorType);
185  itkGetModifiableObjectMacro(Calculator, CalculatorType);
187 
188 #ifdef ITK_USE_CONCEPT_CHECKING
189  // Begin concept checking
190  itkConceptMacro(OutputEqualityComparableCheck,
192  itkConceptMacro(InputOStreamWritableCheck,
194  itkConceptMacro(OutputOStreamWritableCheck,
196  // End concept checking
197 #endif
198 
199 protected:
202  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
203 
204  void GenerateInputRequestedRegion() ITK_OVERRIDE;
205  void GenerateData () ITK_OVERRIDE;
206 
207 private:
208  ITK_DISALLOW_COPY_AND_ASSIGN(HistogramThresholdImageFilter);
209 
210  OutputPixelType m_InsideValue;
212  InputPixelType m_Threshold;
213  MaskPixelType m_MaskValue;
214  CalculatorPointer m_Calculator;
215  unsigned m_NumberOfHistogramBins;
216  bool m_AutoMinimumMaximum;
217  bool m_MaskOutput;
218 };
219 
220 } // end namespace itk
221 
222 #ifndef ITK_MANUAL_INSTANTIATION
223 #include "itkHistogramThresholdImageFilter.hxx"
224 #endif
225 
226 #endif
Threshold an image using a HistogramThresholdCalculator.
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.
HistogramType::MeasurementVectorType HistogramMeasurementVectorType
NumericTraits< ValueType >::RealType ValueRealType
HistogramType::MeasurementType HistogramMeasurementType
Superclass::MeasurementVectorType MeasurementVectorType
Definition: itkHistogram.h:101
TMeasurement MeasurementType
Definition: itkHistogram.h:95
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