#include "stdafx.h" #if defined (_MSC_VER) && (_MSC_VER >= 1000) #pragma once #endif #ifndef _PHYS_LEVEL_SET_H #define _PHYS_LEVEL_SET_H #include "Physics.h" #include "Geom_MeshSpatialObject.h" #include "Geometric.h" #include #include "itkImage.h" #include "itkRescaleIntensityImageFilter.h" #include "itkGeodesicActiveContourLevelSetImageFilter.h" #include "itkCurvatureAnisotropicDiffusionImageFilter.h" #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h" #include "itkSigmoidImageFilter.h" #include "itkFastMarchingImageFilter.h" #include "itkRescaleIntensityImageFilter.h" #include "itkBinaryThresholdImageFilter.h" #include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "itkCastImageFilter.h" #include "itkBinaryMask3DMeshSource.h" #include "itkSpatialObjectToImageFilter.h" #include "itkSignedDanielssonDistanceMapImageFilter.h" #include "LevelSetDeformation.h" #define DEBUG 0 namespace mial { //! A derived physics class capable of carrying out deformations of a spring mass system. /*! A derived class of the physical ABC, this class provides the framework with the ability to simulate deformation dynamics using a geodesic active contour approach[1]. This class is considered to be relatively stable, in that additional functionality may be added but current functionality will remain. [1] Vincent Caselles, Ron Kimmel, and Guillermo Sapiro. Geodesic active contours. In ICCV, pages 694699, 1995. \param DataType The data type to be used for internal storage. \param InputImageType The data type used for the input image \param nDims The number of dimensions used for simulations. \param MType The type of matrix used for internal storage. Defaults to vnl_matrix, the only supported type at this time. \param VType The type of vector used for internal storage. Defaults to vnl_vector, the only supported type at this time. */ template, class VType = vnl_vector > class Phys_LevelSet : public Physics< DataType, nDims, MType, VType > { public: typedef Phys_LevelSet Self; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; typedef itk::WeakPointer ConstWeakPointer; itkNewMacro(Self); typedef typename Physics::Error Error; typedef typename itk::Image< DataType, nDims > InternalImageType; typedef typename Geometric< DataType, nDims >::BinaryImageType BinaryImageType; private: typename InputImageType::ConstPointer inputImg; typename InternalImageType::Pointer distanceImg; typename InternalImageType::Pointer edgePotentialImg; double propagationScaling; double curvatureScaling; double advectionScaling; double maximumRMSError; double numIterations; typename BinaryImageType::Pointer outputImg; public: typedef LevelSetDeformation DeformationType; virtual void initializeDistanceImg(); virtual void initializeEdgePotentialImg(); // functions which are pure virtual in the Physics ABC: virtual bool simulate(); virtual bool runDeformation(const std::string defName,typename DeformationType::deformationIn* const i,std::stringstream * const s = NULL); virtual void setExternalForces( void * ); //-------------------- //! Set the layer's input image. /*! \param img the image to be used by the layer for gradient magnitude calculations. */ virtual void setInput( typename InputImageType::ConstPointer img ){ inputImg = img; } // inline virtual void setPropagationScaling( const double ps ) { propagationScaling = ps; } // inline virtual void setCurvatureScaling( const double cs ) { curvatureScaling = cs; } // inline virtual void setAdvectionScaling( const double as ) { advectionScaling = as; } // inline virtual void setMaximumRMSError( const double me ) { maximumRMSError = me; } // inline virtual void setNumIterations( const double ni ) { numIterations = ni; } // inline virtual double getPropagationScaling() { return this->propagationScaling; } // inline virtual double getCurvatureScaling() { return this->curvatureScaling; } // inline virtual double getAdvectionScaling() { return this->advectionScaling; } // inline virtual double getMaximumRMSError() { return this->maximumRMSError; } // inline virtual double getNumIterations() { return this->numIterations; } // inline // DEBUG TEMP FUNCTIONS: void printInternalValues(); typename InternalImageType::Pointer getDistanceImage() { return this->distanceImg; } // DEBUG inline typename InternalImageType::Pointer getEdgePotentialImage() { return this->edgePotentialImg; } // DEBUG inline typename BinaryImageType::Pointer getOutputImage() { return this->outputImg; } // DEBUG inline protected: Phys_LevelSet(); // constructor }; } // end namespace mial #include "Phys_LevelSet.cxx" #endif // _PHYS_LEVEL_SET_H include