ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkMahalanobisDistanceThresholdImageFunction.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkMahalanobisDistanceThresholdImageFunction_h
00019 #define __itkMahalanobisDistanceThresholdImageFunction_h
00020 
00021 #include "itkImageFunction.h"
00022 #include "itkMahalanobisDistanceMembershipFunction.h"
00023 
00024 namespace itk
00025 {
00048 template< class TInputImage, class TCoordRep = float >
00049 class ITK_EXPORT MahalanobisDistanceThresholdImageFunction:
00050   public ImageFunction< TInputImage, bool, TCoordRep >
00051 {
00052 public:
00054   typedef MahalanobisDistanceThresholdImageFunction     Self;
00055   typedef ImageFunction< TInputImage, bool, TCoordRep > Superclass;
00056   typedef SmartPointer< Self >                          Pointer;
00057   typedef SmartPointer< const Self >                    ConstPointer;
00058 
00060   itkTypeMacro(MahalanobisDistanceThresholdImageFunction, ImageFunction);
00061 
00063   itkNewMacro(Self);
00064 
00066   typedef typename Superclass::InputImageType InputImageType;
00067 
00069   typedef typename TInputImage::PixelType PixelType;
00070 
00072   itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
00073 
00075   typedef typename Superclass::PointType PointType;
00076 
00078   typedef typename Superclass::IndexType IndexType;
00079 
00081   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00082 
00084   typedef vnl_matrix< double > CovarianceMatrixType;
00085 
00087   typedef vnl_vector< double > MeanVectorType;
00088 
00097   virtual bool Evaluate(const PointType & point) const;
00098 
00107   virtual bool EvaluateAtContinuousIndex(
00108     const ContinuousIndexType & index) const;
00109 
00118   virtual bool EvaluateAtIndex(const IndexType & index) const;
00119 
00126   virtual double EvaluateDistance(const PointType & point) const;
00127 
00134   virtual double EvaluateDistanceAtIndex(const IndexType & index) const;
00135 
00137   itkGetConstReferenceMacro(Threshold, double);
00138   itkSetMacro(Threshold, double);
00140 
00142   void SetMean(const MeanVectorType & mean);
00143 
00145   const MeanVectorType & GetMean() const;
00146 
00149   void SetCovariance(const CovarianceMatrixType & cov);
00150 
00152   const CovarianceMatrixType & GetCovariance() const;
00153 
00154 protected:
00155   MahalanobisDistanceThresholdImageFunction();
00156   ~MahalanobisDistanceThresholdImageFunction(){}
00157   void PrintSelf(std::ostream & os, Indent indent) const;
00158 
00159 private:
00160   MahalanobisDistanceThresholdImageFunction(const Self &); //purposely not
00161                                                            // implemented
00162   void operator=(const Self &);                            //purposely not
00163 
00164   // implemented
00165 
00166   double m_Threshold;
00167 
00168   // This is intended only for Image of Vector pixel type.
00169   typedef Statistics::MahalanobisDistanceMembershipFunction<
00170     PixelType
00171     >  MahalanobisDistanceFunctionType;
00172 
00173   typedef typename MahalanobisDistanceFunctionType::Pointer MahalanobisDistanceFunctionPointer;
00174   MahalanobisDistanceFunctionPointer m_MahalanobisDistanceMembershipFunction;
00175 
00176   // Cached versions of the mean and covariance to manage the
00177   // difference in vector/matrix types between this class and the
00178   // membership function used internally.
00179   MeanVectorType       m_Mean;
00180   CovarianceMatrixType m_Covariance;
00181 };
00182 } // end namespace itk
00183 
00184 #ifndef ITK_MANUAL_INSTANTIATION
00185 #include "itkMahalanobisDistanceThresholdImageFunction.hxx"
00186 #endif
00187 
00188 #endif
00189