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(); }
00101
00102
00103 void SetCovariance(const CovarianceMatrixType &cov)
00104 { m_Mahalanobis->SetCovariance(cov); }
00105 const CovarianceMatrixType & GetCovariance() const
00106 { return m_Mahalanobis->GetCovariance(); }
00107
00109 void SetThreshold(ScalarValueType thr)
00110 {
00111 m_Threshold = thr;
00112
00113 }
00114 ScalarValueType GetThreshold()
00115 {
00116 return m_Threshold;
00117 }
00118
00119
00120
00121 virtual void CalculateSpeedImage();
00122
00123 virtual void Initialize(const RadiusType &r)
00124 {
00125 Superclass::Initialize(r);
00126
00127 this->SetAdvectionWeight( NumericTraits<ScalarValueType>::Zero);
00128 this->SetPropagationWeight(-1.0 * NumericTraits<ScalarValueType>::One);
00129 this->SetCurvatureWeight(NumericTraits<ScalarValueType>::One);
00130 }
00131
00132
00133 protected:
00134 VectorThresholdSegmentationLevelSetFunction()
00135 {
00136 MeanVectorType mean( NumberOfComponents );
00137 CovarianceMatrixType covariance( NumberOfComponents, NumberOfComponents );
00138
00139 mean.fill(NumericTraits<ITK_TYPENAME FeatureScalarType::ValueType>::Zero);
00140 covariance.fill(NumericTraits<ITK_TYPENAME FeatureScalarType::ValueType>::Zero);
00141
00142 m_Mahalanobis = MahalanobisFunctionType::New();
00143 m_Mahalanobis->SetMean(mean);
00144 m_Mahalanobis->SetCovariance(covariance);
00145
00146
00147 this->SetAdvectionWeight(0.0);
00148 this->SetPropagationWeight(1.0);
00149 this->SetThreshold(1.8);
00150 }
00151 virtual ~VectorThresholdSegmentationLevelSetFunction(){}
00152
00153 VectorThresholdSegmentationLevelSetFunction(const Self&);
00154 void operator=(const Self&);
00155
00156 void PrintSelf(std::ostream& os, Indent indent) const
00157 {
00158 Superclass::PrintSelf(os, indent );
00159 os << indent << "MahalanobisFunction: " << m_Mahalanobis << std::endl;
00160 os << indent << "ThresholdValue: " << m_Threshold << std::endl;
00161 }
00162
00163
00164 MahalanobisFunctionPointer m_Mahalanobis;
00165 ScalarValueType m_Threshold;
00166
00167 };
00168
00169 }
00170
00171 #ifndef ITK_MANUAL_INSTANTIATION
00172 #include "itkVectorThresholdSegmentationLevelSetFunction.txx"
00173 #endif
00174
00175 #endif
00176