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
00040
template <
class TInputImage,
class TCoordRep =
float>
00041 class ITK_EXPORT BinaryThresholdImageFunction :
00042
public ImageFunction<TInputImage,bool,TCoordRep>
00043 {
00044
public:
00046 typedef BinaryThresholdImageFunction
Self;
00047 typedef ImageFunction<TInputImage,bool,TCoordRep> Superclass;
00048 typedef SmartPointer<Self> Pointer;
00049 typedef SmartPointer<const Self> ConstPointer;
00050
00052
itkTypeMacro(BinaryThresholdImageFunction,
ImageFunction);
00053
00055
itkNewMacro(
Self);
00056
00058 typedef typename Superclass::InputImageType
InputImageType;
00059
00061 typedef typename TInputImage::PixelType
PixelType;
00062
00064
itkStaticConstMacro(ImageDimension,
unsigned int,Superclass::ImageDimension);
00065
00067 typedef typename Superclass::PointType
PointType;
00068
00070 typedef typename Superclass::IndexType
IndexType;
00071
00073 typedef typename Superclass::ContinuousIndexType
ContinuousIndexType;
00074
00084 virtual bool Evaluate(
const PointType& point )
const
00085
{
00086
IndexType index;
00087 this->ConvertPointToNearestIndex( point, index );
00088
return ( this->EvaluateAtIndex( index ) );
00089 }
00090
00099 virtual bool EvaluateAtContinuousIndex(
00100
const ContinuousIndexType & index )
const
00101
{
00102
IndexType nindex;
00103
00104 this->ConvertContinuousIndexToNearestIndex (index, nindex);
00105
return this->EvaluateAtIndex(nindex);
00106 }
00107
00116 virtual bool EvaluateAtIndex(
const IndexType & index )
const
00117
{
00118
PixelType value = m_Image->GetPixel(index);
00119
return ( m_Lower <= value && value <= m_Upper);
00120 }
00121
00123
itkGetConstMacro(Lower,PixelType);
00124
00126
itkGetConstMacro(Upper,PixelType);
00127
00129
void ThresholdAbove(PixelType thresh);
00130
00132
void ThresholdBelow(PixelType thresh);
00133
00135
void ThresholdBetween(PixelType lower, PixelType upper);
00136
00137
protected:
00138 BinaryThresholdImageFunction();
00139 ~BinaryThresholdImageFunction(){};
00140 void PrintSelf(std::ostream& os,
Indent indent)
const;
00141
00142
private:
00143 BinaryThresholdImageFunction(
const Self& );
00144
void operator=(
const Self& );
00145
00146
PixelType m_Lower;
00147
PixelType m_Upper;
00148 };
00149
00150 }
00151
00152
#ifndef ITK_MANUAL_INSTANTIATION
00153
#include "itkBinaryThresholdImageFunction.txx"
00154
#endif
00155
00156
#endif