00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkSegmentationLevelSetImageFilter_h_
00018 #define __itkSegmentationLevelSetImageFilter_h_
00019
00020 #include "itkSparseFieldLevelSetImageFilter.h"
00021 #include "itkSegmentationLevelSetFunction.h"
00022
00023 namespace itk {
00024
00140 template <class TInputImage,
00141 class TFeatureImage,
00142 class TOutputPixelType = float >
00143 class ITK_EXPORT SegmentationLevelSetImageFilter
00144 : public SparseFieldLevelSetImageFilter<TInputImage, Image<TOutputPixelType,
00145 ::itk::GetImageDimension<TInputImage>::ImageDimension> >
00146 {
00147 public:
00150 typedef SegmentationLevelSetImageFilter Self;
00151
00154 itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
00155
00157 typedef Image<TOutputPixelType, itkGetStaticConstMacro(InputImageDimension)> OutputImageType;
00158
00160 typedef SparseFieldLevelSetImageFilter<TInputImage, OutputImageType> Superclass;
00161 typedef SmartPointer<Self> Pointer;
00162 typedef SmartPointer<const Self> ConstPointer;
00163
00165 typedef typename Superclass::ValueType ValueType;
00166 typedef typename Superclass::IndexType IndexType;
00167 typedef typename Superclass::TimeStepType TimeStepType;
00168 typedef typename Superclass::InputImageType InputImageType;
00169
00171 typedef TFeatureImage FeatureImageType;
00172
00174 typedef SegmentationLevelSetFunction<OutputImageType, FeatureImageType>
00175 SegmentationFunctionType;
00176
00178 typedef typename SegmentationFunctionType::VectorImageType VectorImageType;
00179 typedef typename SegmentationFunctionType::ImageType SpeedImageType;
00180
00182 itkTypeMacro(SegmentationLevelSetImageFilter, SparseFieldLevelSetImageFilter);
00183
00186 void SetMaximumIterations (unsigned int i)
00187 {
00188 itkWarningMacro("SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
00189 this->SetNumberOfIterations(i);
00190 }
00191 unsigned int GetMaximumIterations()
00192 {
00193 itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
00194 return this->GetNumberOfIterations();
00195 }
00196
00199 virtual void SetFeatureImage(const FeatureImageType *f)
00200 {
00201 this->ProcessObject::SetNthInput( 1, const_cast< FeatureImageType * >(f) );
00202 m_SegmentationFunction->SetFeatureImage(f);
00203 }
00204 virtual FeatureImageType * GetFeatureImage()
00205 { return ( static_cast< FeatureImageType *>(this->ProcessObject::GetInput(1)) ); }
00206
00209 virtual void SetInitialImage(InputImageType *f)
00210 {
00211 this->SetInput(f);
00212 }
00213
00217 void SetSpeedImage( SpeedImageType *s )
00218 { m_SegmentationFunction->SetSpeedImage( s ); }
00219
00223 void SetAdvectionImage( VectorImageType *v)
00224 { m_SegmentationFunction->SetAdvectionImage( v ); }
00225
00228 virtual const SpeedImageType *GetSpeedImage() const
00229 { return m_SegmentationFunction->GetSpeedImage(); }
00230
00233 virtual const VectorImageType *GetAdvectionImage() const
00234 { return m_SegmentationFunction->GetAdvectionImage(); }
00235
00239 void SetUseNegativeFeaturesOn()
00240 {
00241 itkWarningMacro( << "SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead" );
00242 this->ReverseExpansionDirectionOn();
00243 }
00244 void SetUseNegativeFeaturesOff()
00245 {
00246 itkWarningMacro( << "SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead" );
00247 this->ReverseExpansionDirectionOff();
00248 }
00249
00252 void SetUseNegativeFeatures( bool u )
00253 {
00254 itkWarningMacro( << "SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead" );
00255 if (u == true)
00256 {
00257 this->SetReverseExpansionDirection(false);
00258 }
00259 else
00260 {
00261 this->SetReverseExpansionDirection(true);
00262 }
00263 }
00264 bool GetUseNegativeFeatures() const
00265 {
00266 itkWarningMacro( << "GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead" );
00267 if ( m_ReverseExpansionDirection == false)
00268 {
00269 return true;
00270 }
00271 else
00272 {
00273 return false;
00274 }
00275 }
00276
00285 itkSetMacro(ReverseExpansionDirection, bool);
00286 itkGetMacro(ReverseExpansionDirection, bool);
00287 itkBooleanMacro(ReverseExpansionDirection);
00288
00294 itkSetMacro(AutoGenerateSpeedAdvection, bool);
00295 itkGetMacro(AutoGenerateSpeedAdvection, bool);
00296 itkBooleanMacro(AutoGenerateSpeedAdvection);
00297
00302 void SetFeatureScaling(ValueType v)
00303 {
00304 if (v != m_SegmentationFunction->GetPropagationWeight())
00305 {
00306 this->SetPropagationScaling(v);
00307 }
00308 if (v != m_SegmentationFunction->GetAdvectionWeight())
00309 {
00310 this->SetAdvectionScaling(v);
00311 }
00312 }
00313
00316 void SetPropagationScaling(ValueType v)
00317 {
00318 if (v != m_SegmentationFunction->GetPropagationWeight())
00319 {
00320 m_SegmentationFunction->SetPropagationWeight(v);
00321 this->Modified();
00322 }
00323 }
00324 ValueType GetPropagationScaling() const
00325 {
00326 return m_SegmentationFunction->GetPropagationWeight();
00327 }
00328
00331 void SetAdvectionScaling(ValueType v)
00332 {
00333 if (v != m_SegmentationFunction->GetAdvectionWeight())
00334 {
00335 m_SegmentationFunction->SetAdvectionWeight(v);
00336 this->Modified();
00337 }
00338 }
00339 ValueType GetAdvectionScaling() const
00340 {
00341 return m_SegmentationFunction->GetAdvectionWeight();
00342 }
00343
00347 void SetCurvatureScaling(ValueType v)
00348 {
00349 if (v != m_SegmentationFunction->GetCurvatureWeight())
00350 {
00351 m_SegmentationFunction->SetCurvatureWeight(v);
00352 this->Modified();
00353 }
00354 }
00355 ValueType GetCurvatureScaling() const
00356 {
00357 return m_SegmentationFunction->GetCurvatureWeight();
00358 }
00359
00360
00362 void SetUseMinimalCurvature( bool b )
00363 {
00364 if ( m_SegmentationFunction->GetUseMinimalCurvature() != b)
00365 {
00366 m_SegmentationFunction->SetUseMinimalCurvature( b );
00367 this->Modified();
00368 }
00369 }
00370 bool GetUseMinimalCurvature() const
00371 {
00372 return m_SegmentationFunction->GetUseMinimalCurvature();
00373 }
00374 void UseMinimalCurvatureOn()
00375 {
00376 this->SetUseMinimalCurvature(true);
00377 }
00378 void UseMinimalCurvatureOff()
00379 {
00380 this->SetUseMinimalCurvature(false);
00381 }
00382
00383
00389 virtual void SetSegmentationFunction(SegmentationFunctionType *s)
00390 {
00391 m_SegmentationFunction = s;
00392
00393 typename SegmentationFunctionType::RadiusType r;
00394 r.Fill( 1 );
00395
00396 m_SegmentationFunction->Initialize(r);
00397 this->SetDifferenceFunction(m_SegmentationFunction);
00398 this->Modified();
00399 }
00400
00401 virtual SegmentationFunctionType *GetSegmentationFunction()
00402 { return m_SegmentationFunction; }
00403
00404
00409 void SetMaximumCurvatureTimeStep(double n)
00410 {
00411 if ( n != m_SegmentationFunction->GetMaximumCurvatureTimeStep() )
00412 {
00413 m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
00414 this->Modified();
00415 }
00416 }
00417 double GetMaximumCurvatureTimeStep() const
00418 {
00419 return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
00420 }
00421
00426 void SetMaximumPropagationTimeStep(double n)
00427 {
00428 if (n != m_SegmentationFunction->GetMaximumPropagationTimeStep() )
00429 {
00430 m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
00431 this->Modified();
00432 }
00433 }
00434 double GetMaximumPropagationTimeStep() const
00435 {
00436 return m_SegmentationFunction->GetMaximumPropagationTimeStep();
00437 }
00438
00442 void GenerateSpeedImage();
00443
00447 void GenerateAdvectionImage();
00448
00449 protected:
00450 virtual ~SegmentationLevelSetImageFilter() {}
00451 SegmentationLevelSetImageFilter(const Self&);
00452 SegmentationLevelSetImageFilter();
00453
00454 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00455
00457 virtual void InitializeIteration()
00458 {
00459 Superclass::InitializeIteration();
00460
00461 this->SetProgress( (float) ((float)this->GetElapsedIterations()
00462 / (float)this->GetNumberOfIterations()) );
00463 }
00464
00467 void GenerateData();
00468
00471 bool m_ReverseExpansionDirection;
00472
00477 bool m_AutoGenerateSpeedAdvection;
00478
00479 private:
00480 SegmentationFunctionType *m_SegmentationFunction;
00481 };
00482
00483 }
00484
00485 #ifndef ITK_MANUAL_INSTANTIATION
00486 #include "itkSegmentationLevelSetImageFilter.txx"
00487 #endif
00488
00489 #endif
00490