ITK  4.9.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 
59 template<typename TInputImage, typename TOutputImage, typename TMaskImage=TOutputImage>
61  public ImageToImageFilter<TInputImage, TOutputImage>
62 {
63 public:
69 
71  itkNewMacro(Self);
72 
75 
76  typedef TInputImage InputImageType;
77  typedef TOutputImage OutputImageType;
78  typedef TMaskImage MaskImageType;
79 
81  typedef typename InputImageType::PixelType InputPixelType;
82  typedef typename OutputImageType::PixelType OutputPixelType;
83  typedef typename MaskImageType::PixelType MaskPixelType;
84 
86  typedef typename InputImageType::Pointer InputImagePointer;
87  typedef typename OutputImageType::Pointer OutputImagePointer;
88  typedef typename MaskImageType::Pointer MaskImagePointer;
89 
90  typedef typename InputImageType::SizeType InputSizeType;
91  typedef typename InputImageType::IndexType InputIndexType;
92  typedef typename InputImageType::RegionType InputImageRegionType;
93  typedef typename OutputImageType::SizeType OutputSizeType;
94  typedef typename OutputImageType::IndexType OutputIndexType;
95  typedef typename OutputImageType::RegionType OutputImageRegionType;
96  typedef typename MaskImageType::SizeType MaskSizeType;
97  typedef typename MaskImageType::IndexType MaskIndexType;
98  typedef typename MaskImageType::RegionType MaskImageRegionType;
99 
111 
113  itkStaticConstMacro(InputImageDimension, unsigned int,
114  InputImageType::ImageDimension );
115  itkStaticConstMacro(OutputImageDimension, unsigned int,
116  OutputImageType::ImageDimension );
117  itkStaticConstMacro(MaskImageDimension, unsigned int,
118  MaskImageType::ImageDimension );
120 
124  void SetMaskImage(const TMaskImage *input)
125  {
126  // Process object is not const-correct so the const casting is required.
127  this->SetNthInput( 1, const_cast< TMaskImage * >( input ) );
128  }
129 
131  const MaskImageType * GetMaskImage() const
132  {
133  return itkDynamicCastInDebugMode< MaskImageType * >
134  (const_cast< DataObject * >( this->ProcessObject::GetInput(1) ) );
135  }
136 
138  void SetInput1(const TInputImage *input)
139  {
140  this->SetInput(input);
141  }
142 
144  void SetInput2(const TMaskImage *input)
145  {
146  this->SetMaskImage(input);
147  }
148 
151  itkSetMacro(OutsideValue,OutputPixelType);
152 
154  itkGetConstMacro(OutsideValue,OutputPixelType);
155 
158  itkSetMacro(InsideValue,OutputPixelType);
159 
161  itkGetConstMacro(InsideValue,OutputPixelType);
162 
164  itkSetMacro(NumberOfHistogramBins, unsigned int);
165  itkGetConstMacro(NumberOfHistogramBins, unsigned int);
167 
170  itkSetMacro(AutoMinimumMaximum, bool);
171  itkGetConstMacro(AutoMinimumMaximum, bool);
172  itkBooleanMacro(AutoMinimumMaximum);
174 
178  itkSetMacro(MaskOutput, bool);
179  itkGetConstMacro(MaskOutput, bool);
180  itkBooleanMacro(MaskOutput);
182 
186  itkSetMacro(MaskValue, MaskPixelType);
187  itkGetConstMacro(MaskValue, MaskPixelType);
189 
191  itkGetConstMacro(Threshold,InputPixelType);
192 
194  itkSetObjectMacro(Calculator, CalculatorType);
195  itkGetModifiableObjectMacro(Calculator, CalculatorType);
197 
198 #ifdef ITK_USE_CONCEPT_CHECKING
199  // Begin concept checking
200  itkConceptMacro(OutputEqualityComparableCheck,
202  itkConceptMacro(InputOStreamWritableCheck,
204  itkConceptMacro(OutputOStreamWritableCheck,
206  // End concept checking
207 #endif
208 
209 protected:
212  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
213 
214  void GenerateInputRequestedRegion() ITK_OVERRIDE;
215  void GenerateData () ITK_OVERRIDE;
216 
225 
226 private:
227  HistogramThresholdImageFilter(const Self&) ITK_DELETE_FUNCTION;
228  void operator=(const Self&) ITK_DELETE_FUNCTION;
229 
230 }; // end of class
231 
232 } // end namespace itk
233 
234 #ifndef ITK_MANUAL_INSTANTIATION
235 #include "itkHistogramThresholdImageFilter.hxx"
236 #endif
237 
238 #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
virtual void SetInput(const InputImageType *image)
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 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.
virtual void SetNthInput(DataObjectPointerArraySizeType num, DataObject *input)
Base class to compute a threshold value based on the histogram of an image.
#define itkConceptMacro(name, concept)
void GenerateInputRequestedRegion() override
Base class for all data objects in ITK.
ImageToImageFilter< TInputImage, TOutputImage > Superclass
void PrintSelf(std::ostream &os, Indent indent) const override