00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkBinaryThresholdImageFilter_h
00018 #define __itkBinaryThresholdImageFilter_h
00019
00020 #include "itkUnaryFunctorImageFilter.h"
00021 #include "itkConceptChecking.h"
00022 #include "itkSimpleDataObjectDecorator.h"
00023
00024 namespace itk
00025 {
00026
00044 namespace Functor {
00045
00046 template< class TInput, class TOutput>
00047 class BinaryThreshold
00048 {
00049 public:
00050 BinaryThreshold() {};
00051 ~BinaryThreshold() {};
00052
00053 void SetLowerThreshold( const TInput & thresh )
00054 { m_LowerThreshold = thresh; }
00055 void SetUpperThreshold( const TInput & thresh )
00056 { m_UpperThreshold = thresh; }
00057 void SetInsideValue( const TOutput & value )
00058 { m_InsideValue = value; }
00059 void SetOutsideValue( const TOutput & value )
00060 { m_OutsideValue = value; }
00061
00062 inline TOutput operator()( const TInput & A )
00063 {
00064 if ( m_LowerThreshold <= A && A <= m_UpperThreshold )
00065 {
00066 return m_InsideValue;
00067 }
00068 return m_OutsideValue;
00069 }
00070
00071 private:
00072 TInput m_LowerThreshold;
00073 TInput m_UpperThreshold;
00074 TOutput m_InsideValue;
00075 TOutput m_OutsideValue;
00076
00077 };
00078 }
00079
00080 template <class TInputImage, class TOutputImage>
00081 class ITK_EXPORT BinaryThresholdImageFilter :
00082 public
00083 UnaryFunctorImageFilter<TInputImage,TOutputImage,
00084 Functor::BinaryThreshold<
00085 typename TInputImage::PixelType,
00086 typename TOutputImage::PixelType> >
00087 {
00088 public:
00090 typedef BinaryThresholdImageFilter Self;
00091 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage,
00092 Functor::BinaryThreshold<
00093 typename TInputImage::PixelType,
00094 typename TOutputImage::PixelType>
00095 > Superclass;
00096 typedef SmartPointer<Self> Pointer;
00097 typedef SmartPointer<const Self> ConstPointer;
00098
00100 itkNewMacro(Self);
00101
00103 itkTypeMacro(BinaryThresholdImageFilter, UnaryFunctorImageFilter);
00104
00106 typedef typename TInputImage::PixelType InputPixelType;
00107 typedef typename TOutputImage::PixelType OutputPixelType;
00108
00110 itkConceptMacro(PixelTypeComparable, (Concept::Comparable<InputPixelType>));
00111
00113 typedef SimpleDataObjectDecorator<InputPixelType> InputPixelObjectType;
00114
00117 itkSetMacro(OutsideValue,OutputPixelType);
00118
00120 itkGetMacro(OutsideValue,OutputPixelType);
00121
00124 itkSetMacro(InsideValue,OutputPixelType);
00125
00127 itkGetMacro(InsideValue,OutputPixelType);
00128
00133 virtual void SetUpperThreshold(const InputPixelType threshold);
00134 virtual void SetUpperThresholdInput( const InputPixelObjectType *);
00135 virtual void SetLowerThreshold(const InputPixelType threshold);
00136 virtual void SetLowerThresholdInput( const InputPixelObjectType *);
00137
00139 virtual InputPixelType GetUpperThreshold() const;
00140 virtual InputPixelObjectType *GetUpperThresholdInput();
00141 virtual const InputPixelObjectType *GetUpperThresholdInput() const;
00142 virtual InputPixelType GetLowerThreshold() const;
00143 virtual InputPixelObjectType *GetLowerThresholdInput();
00144 virtual const InputPixelObjectType *GetLowerThresholdInput() const;
00145
00146 protected:
00147 BinaryThresholdImageFilter();
00148 virtual ~BinaryThresholdImageFilter() {}
00149 void PrintSelf(std::ostream& os, Indent indent) const;
00150
00153 virtual void BeforeThreadedGenerateData();
00154
00155 private:
00156 BinaryThresholdImageFilter(const Self&);
00157 void operator=(const Self&);
00158
00159 OutputPixelType m_InsideValue;
00160 OutputPixelType m_OutsideValue;
00161
00162 };
00163
00164 }
00165
00166 #ifndef ITK_MANUAL_INSTANTIATION
00167 #include "itkBinaryThresholdImageFilter.txx"
00168 #endif
00169
00170 #endif