Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkBinaryThresholdImageFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkBinaryThresholdImageFunction.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007-02-07 14:00:14 $
00007   Version:   $Revision: 1.13 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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& ); //purposely not implemented
00146   void operator=( const Self& ); //purposely not implemented
00147 
00148   PixelType m_Lower;
00149   PixelType m_Upper;
00150 };
00151 
00152 } // end namespace itk
00153 
00154 
00155 // Define instantiation macro for this template.
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 

Generated at Tue Sep 15 02:20:52 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000