00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkVectorThresholdSegmentationLevelSetFunction_h_
00018 #define __itkVectorThresholdSegmentationLevelSetFunction_h_
00019
00020 #include "itkSegmentationLevelSetFunction.h"
00021 #include "itkNumericTraits.h"
00022 #include "itkMahalanobisDistanceMembershipFunction.h"
00023 namespace itk {
00024
00054 template <class TImageType, class TFeatureImageType>
00055 class ITK_EXPORT VectorThresholdSegmentationLevelSetFunction
00056 : public SegmentationLevelSetFunction<TImageType, TFeatureImageType>
00057 {
00058 public:
00060 typedef VectorThresholdSegmentationLevelSetFunction Self;
00061 typedef SegmentationLevelSetFunction<TImageType, TFeatureImageType> Superclass;
00062 typedef SmartPointer<Self> Pointer;
00063 typedef SmartPointer<const Self> ConstPointer;
00064 typedef TFeatureImageType FeatureImageType;
00065
00066
00067
00069 itkNewMacro(Self);
00070
00072 itkTypeMacro( VectorThresholdSegmentationLevelSetFunction, SegmentationLevelSetFunction );
00073
00075 typedef typename Superclass::ImageType ImageType;
00076 typedef typename Superclass::ScalarValueType ScalarValueType;
00077 typedef typename Superclass::FeatureScalarType FeatureScalarType;
00078 typedef typename Superclass::RadiusType RadiusType;
00079
00081 itkStaticConstMacro(ImageDimension, unsigned int,
00082 Superclass::ImageDimension);
00083
00085 typedef typename FeatureImageType::PixelType FeatureImagePixelType;
00086 itkStaticConstMacro(NumberOfComponents, unsigned int,
00087 FeatureImagePixelType::Dimension);
00088
00089
00090 typedef Statistics::MahalanobisDistanceMembershipFunction<FeatureScalarType> MahalanobisFunctionType;
00091 typedef typename MahalanobisFunctionType::Pointer MahalanobisFunctionPointer;
00092 typedef typename MahalanobisFunctionType::MeanVectorType MeanVectorType;
00093 typedef typename MahalanobisFunctionType::CovarianceMatrixType CovarianceMatrixType;
00094
00096 void SetMean(const MeanVectorType &mean)
00097 { m_Mahalanobis->SetMean(mean); }
00098 const MeanVectorType & GetMean() const
00099 { return m_Mahalanobis->GetMean(); }
00100
00101
00102 void SetCovariance(const CovarianceMatrixType &cov)
00103 { m_Mahalanobis->SetCovariance(cov); }
00104 const CovarianceMatrixType & GetCovariance() const
00105 { return m_Mahalanobis->GetCovariance(); }
00106
00108 void SetThreshold(ScalarValueType thr)
00109 {
00110 m_Threshold = thr;
00111
00112 }
00113 ScalarValueType GetThreshold()
00114 {
00115 return m_Threshold;
00116 }
00117
00118
00119
00120 virtual void CalculateSpeedImage();
00121
00122 virtual void Initialize(const RadiusType &r)
00123 {
00124 Superclass::Initialize(r);
00125
00126 this->SetAdvectionWeight( NumericTraits<ScalarValueType>::Zero);
00127 this->SetPropagationWeight(-1.0 * NumericTraits<ScalarValueType>::One);
00128 this->SetCurvatureWeight(NumericTraits<ScalarValueType>::One);
00129 }
00130
00131
00132 protected:
00133 VectorThresholdSegmentationLevelSetFunction()
00134 {
00135 MeanVectorType mean( NumberOfComponents );
00136 CovarianceMatrixType covariance( NumberOfComponents, NumberOfComponents );
00137
00138 mean.fill(NumericTraits<ITK_TYPENAME FeatureScalarType::ValueType>::Zero);
00139 covariance.fill(NumericTraits<ITK_TYPENAME FeatureScalarType::ValueType>::Zero);
00140
00141 m_Mahalanobis = MahalanobisFunctionType::New();
00142 m_Mahalanobis->SetMean(mean);
00143 m_Mahalanobis->SetCovariance(covariance);
00144
00145
00146 this->SetAdvectionWeight(0.0);
00147 this->SetPropagationWeight(1.0);
00148 this->SetThreshold(1.8);
00149 }
00150 virtual ~VectorThresholdSegmentationLevelSetFunction(){}
00151
00152 VectorThresholdSegmentationLevelSetFunction(const Self&);
00153 void operator=(const Self&);
00154
00155 void PrintSelf(std::ostream& os, Indent indent) const
00156 {
00157 Superclass::PrintSelf(os, indent );
00158 os << indent << "MahalanobisFunction: " << m_Mahalanobis << std::endl;
00159 os << indent << "ThresholdValue: " << m_Threshold << std::endl;
00160 }
00161
00162
00163 MahalanobisFunctionPointer m_Mahalanobis;
00164 ScalarValueType m_Threshold;
00165
00166 };
00167
00168 }
00169
00170 #ifndef ITK_MANUAL_INSTANTIATION
00171 #include "itkVectorThresholdSegmentationLevelSetFunction.txx"
00172 #endif
00173
00174 #endif