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:
00148
00151 typedef SegmentationLevelSetImageFilter Self;
00152
00155 itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
00156
00158 typedef Image<TOutputPixelType, itkGetStaticConstMacro(InputImageDimension)> OutputImageType;
00159
00161 typedef SparseFieldLevelSetImageFilter<TInputImage, OutputImageType> Superclass;
00162 typedef SmartPointer<Self> Pointer;
00163 typedef SmartPointer<const Self> ConstPointer;
00164
00166 typedef typename Superclass::ValueType ValueType;
00167 typedef typename Superclass::IndexType IndexType;
00168 typedef typename Superclass::TimeStepType TimeStepType;
00169 typedef typename Superclass::InputImageType InputImageType;
00170
00172 typedef TFeatureImage FeatureImageType;
00173
00175 typedef SegmentationLevelSetFunction<OutputImageType, FeatureImageType>
00176 SegmentationFunctionType;
00177
00179 typedef typename SegmentationFunctionType::VectorImageType VectorImageType;
00180 typedef typename SegmentationFunctionType::ImageType SpeedImageType;
00181
00183 itkTypeMacro(SegmentationLevelSetImageFilter, SparseFieldLevelSetImageFilter);
00184
00187 void SetMaximumIterations (unsigned int i)
00188 {
00189 itkWarningMacro("SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
00190 this->SetNumberOfIterations(i);
00191 }
00192 unsigned int GetMaximumIterations()
00193 {
00194 itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
00195 return this->GetNumberOfIterations();
00196 }
00198
00201 virtual void SetFeatureImage(const FeatureImageType *f)
00202 {
00203 this->ProcessObject::SetNthInput( 1, const_cast< FeatureImageType * >(f) );
00204 m_SegmentationFunction->SetFeatureImage(f);
00205 }
00206 virtual FeatureImageType * GetFeatureImage()
00207 { return ( static_cast< FeatureImageType *>(this->ProcessObject::GetInput(1)) ); }
00209
00212 virtual void SetInitialImage(InputImageType *f)
00213 {
00214 this->SetInput(f);
00215 }
00216
00220 void SetSpeedImage( SpeedImageType *s )
00221 { m_SegmentationFunction->SetSpeedImage( s ); }
00222
00226 void SetAdvectionImage( VectorImageType *v)
00227 { m_SegmentationFunction->SetAdvectionImage( v ); }
00228
00231 virtual const SpeedImageType *GetSpeedImage() const
00232 { return m_SegmentationFunction->GetSpeedImage(); }
00233
00236 virtual const VectorImageType *GetAdvectionImage() const
00237 { return m_SegmentationFunction->GetAdvectionImage(); }
00238
00242 void SetUseNegativeFeaturesOn()
00243 {
00244 itkWarningMacro( << "SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead" );
00245 this->ReverseExpansionDirectionOn();
00246 }
00247 void SetUseNegativeFeaturesOff()
00248 {
00249 itkWarningMacro( << "SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead" );
00250 this->ReverseExpansionDirectionOff();
00251 }
00253
00256 void SetUseNegativeFeatures( bool u )
00257 {
00258 itkWarningMacro( << "SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead" );
00259 if (u == true)
00260 {
00261 this->SetReverseExpansionDirection(false);
00262 }
00263 else
00264 {
00265 this->SetReverseExpansionDirection(true);
00266 }
00267 }
00268 bool GetUseNegativeFeatures() const
00269 {
00270 itkWarningMacro( << "GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead" );
00271 if ( m_ReverseExpansionDirection == false)
00272 {
00273 return true;
00274 }
00275 else
00276 {
00277 return false;
00278 }
00279 }
00281
00290 itkSetMacro(ReverseExpansionDirection, bool);
00291 itkGetMacro(ReverseExpansionDirection, bool);
00292 itkBooleanMacro(ReverseExpansionDirection);
00294
00300 itkSetMacro(AutoGenerateSpeedAdvection, bool);
00301 itkGetMacro(AutoGenerateSpeedAdvection, bool);
00302 itkBooleanMacro(AutoGenerateSpeedAdvection);
00304
00309 void SetFeatureScaling(ValueType v)
00310 {
00311 if (v != m_SegmentationFunction->GetPropagationWeight())
00312 {
00313 this->SetPropagationScaling(v);
00314 }
00315 if (v != m_SegmentationFunction->GetAdvectionWeight())
00316 {
00317 this->SetAdvectionScaling(v);
00318 }
00319 }
00321
00324 void SetPropagationScaling(ValueType v)
00325 {
00326 if (v != m_SegmentationFunction->GetPropagationWeight())
00327 {
00328 m_SegmentationFunction->SetPropagationWeight(v);
00329 this->Modified();
00330 }
00331 }
00332 ValueType GetPropagationScaling() const
00333 {
00334 return m_SegmentationFunction->GetPropagationWeight();
00335 }
00337
00340 void SetAdvectionScaling(ValueType v)
00341 {
00342 if (v != m_SegmentationFunction->GetAdvectionWeight())
00343 {
00344 m_SegmentationFunction->SetAdvectionWeight(v);
00345 this->Modified();
00346 }
00347 }
00348 ValueType GetAdvectionScaling() const
00349 {
00350 return m_SegmentationFunction->GetAdvectionWeight();
00351 }
00353
00357 void SetCurvatureScaling(ValueType v)
00358 {
00359 if (v != m_SegmentationFunction->GetCurvatureWeight())
00360 {
00361 m_SegmentationFunction->SetCurvatureWeight(v);
00362 this->Modified();
00363 }
00364 }
00365 ValueType GetCurvatureScaling() const
00366 {
00367 return m_SegmentationFunction->GetCurvatureWeight();
00368 }
00370
00371
00373 void SetUseMinimalCurvature( bool b )
00374 {
00375 if ( m_SegmentationFunction->GetUseMinimalCurvature() != b)
00376 {
00377 m_SegmentationFunction->SetUseMinimalCurvature( b );
00378 this->Modified();
00379 }
00380 }
00381 bool GetUseMinimalCurvature() const
00382 {
00383 return m_SegmentationFunction->GetUseMinimalCurvature();
00384 }
00385 void UseMinimalCurvatureOn()
00386 {
00387 this->SetUseMinimalCurvature(true);
00388 }
00389 void UseMinimalCurvatureOff()
00390 {
00391 this->SetUseMinimalCurvature(false);
00392 }
00394
00395
00401 virtual void SetSegmentationFunction(SegmentationFunctionType *s)
00402 {
00403 m_SegmentationFunction = s;
00404
00405 typename SegmentationFunctionType::RadiusType r;
00406 r.Fill( 1 );
00407
00408 m_SegmentationFunction->Initialize(r);
00409 this->SetDifferenceFunction(m_SegmentationFunction);
00410 this->Modified();
00411 }
00412
00413 virtual SegmentationFunctionType *GetSegmentationFunction()
00414 { return m_SegmentationFunction; }
00415
00416
00421 void SetMaximumCurvatureTimeStep(double n)
00422 {
00423 if ( n != m_SegmentationFunction->GetMaximumCurvatureTimeStep() )
00424 {
00425 m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
00426 this->Modified();
00427 }
00428 }
00429 double GetMaximumCurvatureTimeStep() const
00430 {
00431 return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
00432 }
00434
00439 void SetMaximumPropagationTimeStep(double n)
00440 {
00441 if (n != m_SegmentationFunction->GetMaximumPropagationTimeStep() )
00442 {
00443 m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
00444 this->Modified();
00445 }
00446 }
00447 double GetMaximumPropagationTimeStep() const
00448 {
00449 return m_SegmentationFunction->GetMaximumPropagationTimeStep();
00450 }
00452
00456 void GenerateSpeedImage();
00457
00461 void GenerateAdvectionImage();
00462
00463 #ifdef ITK_USE_CONCEPT_CHECKING
00464
00465 itkConceptMacro(OutputHasNumericTraitsCheck,
00466 (Concept::HasNumericTraits<TOutputPixelType>));
00467
00469 #endif
00470
00471 protected:
00472 virtual ~SegmentationLevelSetImageFilter() {}
00473 SegmentationLevelSetImageFilter(const Self&);
00474 SegmentationLevelSetImageFilter();
00475
00476 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00477
00479 virtual void InitializeIteration()
00480 {
00481 Superclass::InitializeIteration();
00482
00483 this->SetProgress( (float) ((float)this->GetElapsedIterations()
00484 / (float)this->GetNumberOfIterations()) );
00485 }
00487
00490 void GenerateData();
00491
00494 bool m_ReverseExpansionDirection;
00495
00500 bool m_AutoGenerateSpeedAdvection;
00501
00502 private:
00503 SegmentationFunctionType *m_SegmentationFunction;
00504 };
00505
00506 }
00507
00508 #ifndef ITK_MANUAL_INSTANTIATION
00509 #include "itkSegmentationLevelSetImageFilter.txx"
00510 #endif
00511
00512 #endif
00513
00514