itkBinaryThresholdImageFunction.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkBinaryThresholdImageFunction_h
00018 #define __itkBinaryThresholdImageFunction_h
00019
00020 #include "itkImageFunction.h"
00021
00022 namespace itk
00023 {
00024
00041 template <class TInputImage, class TCoordRep = float>
00042 class ITK_EXPORT BinaryThresholdImageFunction :
00043 public ImageFunction<TInputImage,bool,TCoordRep>
00044 {
00045 public:
00047 typedef BinaryThresholdImageFunction Self;
00048 typedef ImageFunction<TInputImage,bool,TCoordRep> Superclass;
00049 typedef SmartPointer<Self> Pointer;
00050 typedef SmartPointer<const Self> ConstPointer;
00051
00053 itkTypeMacro(BinaryThresholdImageFunction, ImageFunction);
00054
00056 itkNewMacro(Self);
00057
00059 typedef typename Superclass::InputImageType InputImageType;
00060
00062 typedef typename TInputImage::PixelType PixelType;
00063
00065 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00066
00068 typedef typename Superclass::PointType PointType;
00069
00071 typedef typename Superclass::IndexType IndexType;
00072
00074 typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00075
00085 virtual bool Evaluate( const PointType& point ) const
00086 {
00087 IndexType index;
00088 this->ConvertPointToNearestIndex( point, index );
00089 return ( this->EvaluateAtIndex( index ) );
00090 }
00091
00100 virtual bool EvaluateAtContinuousIndex(
00101 const ContinuousIndexType & index ) const
00102 {
00103 IndexType nindex;
00104
00105 this->ConvertContinuousIndexToNearestIndex (index, nindex);
00106 return this->EvaluateAtIndex(nindex);
00107 }
00108
00117 virtual bool EvaluateAtIndex( const IndexType & index ) const
00118 {
00119 PixelType value = this->GetInputImage()->GetPixel(index);
00120 return ( m_Lower <= value && value <= m_Upper);
00121 }
00123
00125 itkGetConstReferenceMacro(Lower,PixelType);
00126
00128 itkGetConstReferenceMacro(Upper,PixelType);
00129
00131 void ThresholdAbove(PixelType thresh);
00132
00134 void ThresholdBelow(PixelType thresh);
00135
00137 void ThresholdBetween(PixelType lower, PixelType upper);
00138
00139 protected:
00140 BinaryThresholdImageFunction();
00141 ~BinaryThresholdImageFunction(){};
00142 void PrintSelf(std::ostream& os, Indent indent) const;
00143
00144 private:
00145 BinaryThresholdImageFunction( const Self& );
00146 void operator=( const Self& );
00147
00148 PixelType m_Lower;
00149 PixelType m_Upper;
00150 };
00151
00152 }
00153
00154
00155
00156 #define ITK_TEMPLATE_BinaryThresholdImageFunction(_, EXPORT, x, y) namespace itk { \
00157 _(2(class EXPORT BinaryThresholdImageFunction< ITK_TEMPLATE_2 x >)) \
00158 namespace Templates { typedef BinaryThresholdImageFunction< ITK_TEMPLATE_2 x > \
00159 BinaryThresholdImageFunction##y; } \
00160 }
00161
00162 #if ITK_TEMPLATE_EXPLICIT
00163 # include "Templates/itkBinaryThresholdImageFunction+-.h"
00164 #endif
00165
00166 #if ITK_TEMPLATE_TXX
00167 # include "itkBinaryThresholdImageFunction.txx"
00168 #endif
00169
00170 #endif
00171