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

itkMahalanobisDistanceThresholdImageFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkMahalanobisDistanceThresholdImageFunction.h,v $
00005   Language:  C++
00006   Date:      $Date: 2003/09/10 14:29:14 $
00007   Version:   $Revision: 1.3 $
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 _itkMahalanobisDistanceThresholdImageFunction_h
00018 #define _itkMahalanobisDistanceThresholdImageFunction_h
00019 
00020 #include "itkImageFunction.h"
00021 #include "itkMahalanobisDistanceMembershipFunction.h"
00022 
00023 namespace itk
00024 {
00025 
00046 template <class TInputImage, class TCoordRep = float>
00047 class ITK_EXPORT MahalanobisDistanceThresholdImageFunction : 
00048   public ImageFunction<TInputImage,bool,TCoordRep> 
00049 {
00050 public:
00052   typedef MahalanobisDistanceThresholdImageFunction Self;
00053   typedef ImageFunction<TInputImage,bool,TCoordRep> Superclass;
00054   typedef SmartPointer<Self> Pointer;
00055   typedef SmartPointer<const Self>  ConstPointer;
00056   
00058   itkTypeMacro(MahalanobisDistanceThresholdImageFunction, ImageFunction);
00059 
00061   itkNewMacro(Self);
00062 
00064   typedef typename Superclass::InputImageType InputImageType;
00065   
00067   typedef typename TInputImage::PixelType PixelType;
00068 
00070   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00071 
00073   typedef typename Superclass::PointType PointType;
00074 
00076   typedef typename Superclass::IndexType IndexType;
00077 
00079   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00080 
00082   typedef vnl_matrix<double> CovarianceMatrixType;
00083   
00085   typedef vnl_vector<double> MeanVectorType;
00086   
00096   virtual bool Evaluate( const PointType& point ) const
00097     {
00098     IndexType index;
00099     this->ConvertPointToNearestIndex( point, index );
00100     return ( this->EvaluateAtIndex( index ) );
00101     }
00102 
00111   virtual bool EvaluateAtContinuousIndex( 
00112     const ContinuousIndexType & index ) const
00113     {
00114       IndexType nindex;
00115 
00116       this->ConvertContinuousIndexToNearestIndex (index, nindex);
00117       return this->EvaluateAtIndex(nindex);
00118     }
00119 
00128   virtual bool EvaluateAtIndex( const IndexType & index ) const
00129     {
00130     double mahalanobisDistance = 
00131       m_MahalanobisDistanceMembershipFunction->Evaluate( 
00132                                         m_Image->GetPixel( index ) );
00133     return ( sqrt( mahalanobisDistance ) <= m_Threshold );
00134     }
00135 
00137   itkGetConstMacro(Threshold,double);
00138   itkSetMacro(Threshold,double);
00139 
00141   void SetMean(const MeanVectorType &mean);
00142   const MeanVectorType & GetMean() const;
00143  
00148   void SetCovariance(const CovarianceMatrixType &cov); 
00149   const CovarianceMatrixType & GetCovariance() const;
00150   
00151 
00152 protected:
00153   MahalanobisDistanceThresholdImageFunction();
00154   ~MahalanobisDistanceThresholdImageFunction(){};
00155   void PrintSelf(std::ostream& os, Indent indent) const;
00156 
00157 private:
00158   MahalanobisDistanceThresholdImageFunction( const Self& ); //purposely not implemented
00159   void operator=( const Self& ); //purposely not implemented
00160 
00161   double  m_Threshold;
00162 
00163   // This is intended only for Image of Vector pixel type.
00164   typedef Statistics::MahalanobisDistanceMembershipFunction<
00165                                             PixelType 
00166                                               >  MahalanobisDistanceFunctionType;
00167 
00168   typedef typename MahalanobisDistanceFunctionType::Pointer MahalanobisDistanceFunctionPointer;
00169   MahalanobisDistanceFunctionPointer m_MahalanobisDistanceMembershipFunction;
00170 
00171 };
00172 
00173 } // namespace itk
00174 
00175 #ifndef ITK_MANUAL_INSTANTIATION
00176 #include "itkMahalanobisDistanceThresholdImageFunction.txx"
00177 #endif
00178 
00179 #endif

Generated at Sun Jan 25 13:19:39 2004 for ITK by doxygen 1.3.3 written by Dimitri van Heesch, © 1997-2000