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
00142
template <
class TInputImage,
00143
class TFeatureImage,
00144
class TOutputPixelType =
float,
00145
class TOutputImage = Image<TOutputPixelType,
00146 ::itk::GetImageDimension<TInputImage>::ImageDimension> >
00147 class ITK_EXPORT SegmentationLevelSetImageFilter
00148 :
public SparseFieldLevelSetImageFilter<TInputImage, TOutputImage>
00149 {
00150
public:
00152
typedef SegmentationLevelSetImageFilter
Self;
00153 typedef SparseFieldLevelSetImageFilter<TInputImage, TOutputImage> Superclass;
00154 typedef SmartPointer<Self> Pointer;
00155 typedef SmartPointer<const Self> ConstPointer;
00156
00158
typedef typename Superclass::ValueType
ValueType;
00159 typedef typename Superclass::IndexType
IndexType;
00160 typedef typename Superclass::TimeStepType
TimeStepType;
00161 typedef typename Superclass::InputImageType
InputImageType;
00162
00164
typedef TOutputImage
OutputImageType;
00165 typedef TFeatureImage
FeatureImageType;
00166
00168
typedef SegmentationLevelSetFunction<OutputImageType, FeatureImageType>
00169
SegmentationFunctionType;
00170
00172
typedef typename SegmentationFunctionType::VectorImageType
VectorImageType;
00173
00175
itkTypeMacro(SegmentationLevelSetImageFilter,
SparseFieldLevelSetImageFilter);
00176
00179
void SetMaximumIterations (
unsigned int i)
00180 {
00181
itkWarningMacro(
"SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
00182 this->SetNumberOfIterations(i);
00183 }
00184
unsigned int GetMaximumIterations()
00185 {
00186
itkWarningMacro(
"GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
00187
return this->GetNumberOfIterations();
00188 }
00189
00192
virtual void SetFeatureImage(
const FeatureImageType *f)
00193 {
00194 this->ProcessObject::SetNthInput( 1, const_cast< FeatureImageType * >(f) );
00195 m_SegmentationFunction->SetFeatureImage(f);
00196 }
00197
virtual FeatureImageType * GetFeatureImage()
00198 {
return ( static_cast< FeatureImageType *>(this->ProcessObject::GetInput(1)) ); }
00199
00202
virtual void SetInitialImage(
InputImageType *f)
00203 {
00204 this->SetInput(f);
00205 }
00206
00210
void SetSpeedImage(
typename SegmentationFunctionType::ImageType *s)
00211 { m_SegmentationFunction->SetSpeedImage( s ); }
00212
00216
void SetAdvectionImage(
typename SegmentationFunctionType::VectorImageType *v)
00217 { m_SegmentationFunction->SetAdvectionImage( v ); }
00218
00221
virtual const typename SegmentationFunctionType::ImageType *GetSpeedImage()
const
00222
{
return m_SegmentationFunction->GetSpeedImage(); }
00223
00226
virtual const typename SegmentationFunctionType::VectorImageType *GetAdvectionImage()
const
00227
{
return m_SegmentationFunction->GetAdvectionImage(); }
00228
00232
void SetUseNegativeFeaturesOn()
00233 {
00234
itkWarningMacro( <<
"SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead" );
00235 this->ReverseExpansionDirectionOn();
00236 }
00237
void SetUseNegativeFeaturesOff()
00238 {
00239
itkWarningMacro( <<
"SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead" );
00240 this->ReverseExpansionDirectionOff();
00241 }
00242
00245
void SetUseNegativeFeatures(
bool u )
00246 {
00247
itkWarningMacro( <<
"SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead" );
00248
if (u ==
true)
00249 {
00250 this->SetReverseExpansionDirection(
false);
00251 }
00252
else
00253 {
00254 this->SetReverseExpansionDirection(
true);
00255 }
00256 }
00257
bool GetUseNegativeFeatures()
const
00258
{
00259
itkWarningMacro( <<
"GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead" );
00260
if ( m_ReverseExpansionDirection ==
false)
00261 {
00262
return true;
00263 }
00264
else
00265 {
00266
return false;
00267 }
00268 }
00269
00278
itkSetMacro(ReverseExpansionDirection,
bool);
00279
itkGetMacro(ReverseExpansionDirection,
bool);
00280
itkBooleanMacro(ReverseExpansionDirection);
00281
00287
itkSetMacro(AutoGenerateSpeedAdvection,
bool);
00288
itkGetMacro(AutoGenerateSpeedAdvection,
bool);
00289
itkBooleanMacro(AutoGenerateSpeedAdvection);
00290
00295
void SetFeatureScaling(ValueType v)
00296 {
00297
if (v != m_SegmentationFunction->GetPropagationWeight())
00298 {
00299 this->SetPropagationScaling(v);
00300 }
00301
if (v != m_SegmentationFunction->GetAdvectionWeight())
00302 {
00303 this->SetAdvectionScaling(v);
00304 }
00305 }
00306
00309
void SetPropagationScaling(ValueType v)
00310 {
00311
if (v != m_SegmentationFunction->GetPropagationWeight())
00312 {
00313 m_SegmentationFunction->SetPropagationWeight(v);
00314 this->Modified();
00315 }
00316 }
00317 ValueType GetPropagationScaling()
const
00318
{
00319
return m_SegmentationFunction->GetPropagationWeight();
00320 }
00321
00324
void SetAdvectionScaling(ValueType v)
00325 {
00326
if (v != m_SegmentationFunction->GetAdvectionWeight())
00327 {
00328 m_SegmentationFunction->SetAdvectionWeight(v);
00329 this->Modified();
00330 }
00331 }
00332 ValueType GetAdvectionScaling()
const
00333 {
00334
return m_SegmentationFunction->GetAdvectionWeight();
00335 }
00336
00340
void SetCurvatureScaling(ValueType v)
00341 {
00342
if (v != m_SegmentationFunction->GetCurvatureWeight())
00343 {
00344 m_SegmentationFunction->SetCurvatureWeight(v);
00345 this->Modified();
00346 }
00347 }
00348 ValueType GetCurvatureScaling()
const
00349
{
00350 return m_SegmentationFunction->GetCurvatureWeight();
00351 }
00352
00353
00355
void SetUseMinimalCurvature(
bool b )
00356 {
00357
if ( m_SegmentationFunction->GetUseMinimalCurvature() != b)
00358 {
00359 m_SegmentationFunction->SetUseMinimalCurvature( b );
00360 this->Modified();
00361 }
00362 }
00363
bool GetUseMinimalCurvature()
const
00364
{
00365
return m_SegmentationFunction->GetUseMinimalCurvature();
00366 }
00367
void UseMinimalCurvatureOn()
00368 {
00369 this->SetUseMinimalCurvature(
true);
00370 }
00371
void UseMinimalCurvatureOff()
00372 {
00373 this->SetUseMinimalCurvature(
false);
00374 }
00375
00376
00379
virtual void SetSegmentationFunction(SegmentationFunctionType *s);
00380
virtual SegmentationFunctionType *GetSegmentationFunction()
00381 {
return m_SegmentationFunction; }
00382
00383
00388
void SetMaximumCurvatureTimeStep(
double n)
00389 {
00390
if ( n != m_SegmentationFunction->GetMaximumCurvatureTimeStep() )
00391 {
00392 m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
00393 this->Modified();
00394 }
00395 }
00396
double GetMaximumCurvatureTimeStep()
const
00397
{
00398
return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
00399 }
00400
00405
void SetMaximumPropagationTimeStep(
double n)
00406 {
00407
if (n != m_SegmentationFunction->GetMaximumPropagationTimeStep() )
00408 {
00409 m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
00410 this->Modified();
00411 }
00412 }
00413
double GetMaximumPropagationTimeStep()
const
00414
{
00415
return m_SegmentationFunction->GetMaximumPropagationTimeStep();
00416 }
00417
00421
void GenerateSpeedImage();
00422
00426
void GenerateAdvectionImage();
00427
00428
protected:
00429
virtual ~SegmentationLevelSetImageFilter() {}
00430 SegmentationLevelSetImageFilter(
const Self&);
00431 SegmentationLevelSetImageFilter();
00432
00433
virtual void PrintSelf(std::ostream& os,
Indent indent)
const;
00434
00436
virtual void InitializeIteration()
00437 {
00438 Superclass::InitializeIteration();
00439
00440 this->SetProgress( (
float) ((
float)this->GetElapsedIterations()
00441 / (
float)this->GetNumberOfIterations()) );
00442 }
00443
00446
void GenerateData();
00447
00450
bool m_ReverseExpansionDirection;
00451
00456
bool m_AutoGenerateSpeedAdvection;
00457
00458
private:
00459
SegmentationFunctionType *m_SegmentationFunction;
00460 };
00461
00462 }
00463
00464
#ifndef ITK_MANUAL_INSTANTIATION
00465
#include "itkSegmentationLevelSetImageFilter.txx"
00466 #endif
00467
00468
#endif
00469