KWStyle - itkMahalanobisDistanceThresholdImageFunction.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkMahalanobisDistanceThresholdImageFunction.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:41 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17 DEF #ifndef _itkMahalanobisDistanceThresholdImageFunction_h
18 DEF #define _itkMahalanobisDistanceThresholdImageFunction_h
19
20 #include "itkImageFunction.h"
21 #include "itkMahalanobisDistanceMembershipFunction.h"
22
23 namespace itk
24 {
25
26 /** \class MahalanobisDistanceThresholdImageFunction
27  * \brief Returns true if the pixel value of a vector image has a
28  * Mahalanobis distance below the value specified by the threshold.
29  *
30  * This ImageFunction returns true if the pixel value of a vector image has a
31  * Mahalanobis distance below the value specided by the threshold. The
32  * Mahalanobis distance is computed with the
33  * MahalanobisDistanceMembershipFunction class which has to be initialized with
34  * the mean an covariance to be used. This class is intended to be used only
35  * with images whose pixel type is a vector (array).
36  *
37  * The input image is set via method SetInputImage().
38  *
39  * Methods Evaluate, EvaluateAtIndex and EvaluateAtContinuousIndex respectively
40  * evaluate the function at an geometric point, image index and continuous
41  * image index.
42  *
43  * \ingroup ImageFunctions
44  * 
45  * */
46 template <class TInputImage, class TCoordRep = float>
47 class ITK_EXPORT MahalanobisDistanceThresholdImageFunction : 
48 IND **public ImageFunction<TInputImage,bool,TCoordRep> 
49 {
50 public:
51   /** Standard class typedefs. */
52   typedef MahalanobisDistanceThresholdImageFunction Self;
53   typedef ImageFunction<TInputImage,bool,TCoordRep> Superclass;
54 TDA   typedef SmartPointer<Self> Pointer;
55 TDA   typedef SmartPointer<const Self>  ConstPointer;
56   
57   /** Run-time type information (and related methods). */
58   itkTypeMacro(MahalanobisDistanceThresholdImageFunction, ImageFunction);
59
60   /** Method for creation through the object factory. */
61   itkNewMacro(Self);
62
63   /** InputImageType typedef support. */
64   typedef typename Superclass::InputImageType InputImageType;
65   
66   /** Typedef to describe the type of pixel. */
67   typedef typename TInputImage::PixelType PixelType;
68
69   /** Dimension underlying input image. */
70   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
71
72   /** Point typedef support. */
73   typedef typename Superclass::PointType PointType;
74
75   /** Index typedef support. */
76   typedef typename Superclass::IndexType IndexType;
77
78   /** ContinuousIndex typedef support. */
79   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
80
81   /** Type used to represent the Covariance matrix of the vector population */
82   typedef vnl_matrix<double> CovarianceMatrixType;
83   
84   /** Type used to represent the Mean Vector of the vector population */
85   typedef vnl_vector<double> MeanVectorType;
86   
87   /** BinaryThreshold the image at a point position
88    *
89    * Returns true if the image intensity at the specified point position
90    * satisfies the threshold criteria.  The point is assumed to lie within
91    * the image buffer.
92    *
93    * ImageFunction::IsInsideBuffer() can be used to check bounds before
94    * calling the method. */
95   virtual bool Evaluate( const PointType& point ) const;
96
97   /** BinaryThreshold the image at a continuous index position
98    *
99    * Returns true if the image intensity at the specified point position
100    * satisfies the threshold criteria.  The point is assumed to lie within
101    * the image buffer.
102    *
103    * ImageFunction::IsInsideBuffer() can be used to check bounds before
104    * calling the method. */
105   virtual bool EvaluateAtContinuousIndex( 
106                         const ContinuousIndexType & index ) const;
107
108   /** BinaryThreshold the image at an index position.
109    *
110    * Returns true if the image intensity at the specified point position
111    * satisfies the threshold criteria.  The point is assumed to lie within
112    * the image buffer.
113    *
114    * ImageFunction::IsInsideBuffer() can be used to check bounds before
115    * calling the method. */
116   virtual bool EvaluateAtIndex( const IndexType & index ) const;
117
118   /** 
119    *
120    * Returns the actual value of the MahalanobisDistance at that point.
121    * The point is assumed to lie within the image buffer.
122    * ImageFunction::IsInsideBuffer() can be used to check bounds before
123    * calling the method. */
124   virtual double EvaluateDistance( const PointType& point ) const;
125
126   /** 
127    *
128    * Returns the actual value of the MahalanobisDistance at that Index.
129    * The point is assumed to lie within the image buffer.
130    * ImageFunction::IsInsideBuffer() can be used to check bounds before
131    * calling the method. */
132   virtual double EvaluateDistanceAtIndex( const IndexType & index ) const;
133
134   /** Get the lower threshold value. */
135   itkGetConstReferenceMacro(Threshold,double);
136   itkSetMacro(Threshold,double);
137
138   /** Method to set mean */
139   void SetMean(const MeanVectorType &mean);
140   const MeanVectorType & GetMean() const;
141  
142   /**
143    * Method to set covariance matrix
144    * Also, this function calculates inverse covariance and pre factor of 
145    * MahalanobisDistance Distribution to speed up GetProbability */
146   void SetCovariance(const CovarianceMatrixType &cov); 
147   const CovarianceMatrixType & GetCovariance() const;
148   
149
150 protected:
151   MahalanobisDistanceThresholdImageFunction();
152   ~MahalanobisDistanceThresholdImageFunction(){};
153   void PrintSelf(std::ostream& os, Indent indent) const;
154
155 private:
156 LEN   MahalanobisDistanceThresholdImageFunction( const Self& ); //purposely not implemented
157   void operator=( const Self& ); //purposely not implemented
158
159   double  m_Threshold;
160
161   // This is intended only for Image of Vector pixel type.
162   typedef Statistics::MahalanobisDistanceMembershipFunction<
163                                             PixelType 
164 LEN,IND **********************************************>  MahalanobisDistanceFunctionType;
165
166 LEN   typedef typename MahalanobisDistanceFunctionType::Pointer MahalanobisDistanceFunctionPointer;
167   MahalanobisDistanceFunctionPointer m_MahalanobisDistanceMembershipFunction;
168
169 };
170
171 // namespace itk
172
173 #ifndef ITK_MANUAL_INSTANTIATION
174 #include "itkMahalanobisDistanceThresholdImageFunction.txx"
175 #endif
176
177 #endif
178

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:20PM
© Kitware Inc.