Hi ITK users,<br><br>I am trying to implement CURVES method(Lorigo et. al., 2001). I working with 3D data set and trying to modify the example for 2D. I believe I got the feature image properly. However I can't get the fast marching method work. So i can't get an initial curve. What do you suggest? Thank you in advance.<br>
----------------------------------------------------------------------------<br>Here is my code:<br><br>#include "itkImage.h"<br>#include "itkCurvesLevelSetImageFilter.h"<br>#include "itkCurvatureAnisotropicDiffusionImageFilter.h"<br>
#include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"<br>#include "itkSigmoidImageFilter.h"<br>#include "itkFastMarchingImageFilter.h"<br>#include "itkRescaleIntensityImageFilter.h"<br>
#include "itkBinaryThresholdImageFilter.h"<br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br>#include "itkCurvesLevelSetFunction.h"<br>#include "itkCurvesLevelSetImageFilter.h"<br>
#include <math.h><br>#include "itkExpNegativeImageFilter.h"<br><br>int main (int argc, char *argv[])<br>{<br> <br> const unsigned int Dimension = 3;<br> typedef float InternalPixelType;<br> typedef itk::Image<InternalPixelType,Dimension> InternalImageType;<br>
typedef short ExternalPixelType;<br> typedef itk::Image<ExternalPixelType,Dimension> ExternalImageType;<br> <br> typedef itk::ImageFileReader<InternalImageType> ReaderType;<br> typedef itk::ImageFileWriter<ExternalImageType> WriterType;<br>
typedef itk::RescaleIntensityImageFilter<InternalImageType, ExternalImageType> CasterType;<br> typedef itk::RescaleIntensityImageFilter<InternalImageType, InternalImageType> RescaleFilterType;<br> typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< <br>
InternalImageType, <br> InternalImageType > GradientFilterType;<br> typedef itk::CurvatureAnisotropicDiffusionImageFilter< <br> InternalImageType, <br>
InternalImageType > SmoothingFilterType;<br> typedef itk::SigmoidImageFilter<<br> InternalImageType, <br> InternalImageType > SigmoidFilterType;<br>
typedef itk::ExpNegativeImageFilter<InternalImageType, InternalImageType> ExponentialType;<br> typedef itk::FastMarchingImageFilter<InternalImageType,InternalImageType> FastMarchingType;<br> <br> RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New(); <br>
ReaderType::Pointer reader = ReaderType::New();<br> WriterType::Pointer writer = WriterType::New();<br> CasterType::Pointer caster = CasterType::New();<br> GradientFilterType::Pointer GradientFilter = GradientFilterType::New();<br>
ExponentialType::Pointer ExponentialFilter = ExponentialType::New();<br> FastMarchingType::Pointer fastmarchingfilter = FastMarchingType::New();<br> <br> reader->SetFileName(argv[1]);<br> GradientFilter->SetSigma(1.2);<br>
ExponentialFilter->SetFactor(1.0);<br> GradientFilter->SetInput(reader->GetOutput());<br> rescaleFilter->SetInput(GradientFilter->GetOutput());<br> rescaleFilter->SetOutputMinimum(0);<br> rescaleFilter->SetOutputMaximum(255);<br>
// InternalImageType::Pointer gradientimage = InternalImageType::New(); <br> InternalImageType::Pointer FeatureImage = InternalImageType::New();<br> caster->SetInput(rescaleFilter->GetOutput());<br> writer->SetFileName("gradientimage.mhd");<br>
writer->SetInput(caster->GetOutput());<br> writer->Update();<br> ExponentialFilter->SetInput(rescaleFilter->GetOutput());<br> FeatureImage = ExponentialFilter->GetOutput();<br> caster->SetInput(FeatureImage);<br>
writer->SetFileName("featureimage.mhd");<br> writer->SetInput(caster->GetOutput());<br> writer->Update();<br> <br>// Obtaining the initial curve<br> typedef FastMarchingType::NodeContainer NodeContainer;<br>
typedef FastMarchingType::NodeType NodeType;<br><br> NodeContainer::Pointer seeds = NodeContainer::New();<br><br> InternalImageType::IndexType seedPosition;<br> <br> seedPosition[0] = 110;<br> seedPosition[1] = 110;<br>
seedPosition[2] = 90;<br>// seedPosition[3] = 80;<br>// seedPosition[4] = 250;<br>// seedPosition[5] = 240;<br> const double initialDistance = 10;<br> NodeType node;<br> const double seedValue = initialDistance;<br>
node.SetValue( seedValue );<br> node.SetIndex( seedPosition );<br> seeds->Initialize();<br> seeds->InsertElement( 0, node );<br> seeds->InsertElement( 1, node );<br> seeds->InsertElement(2,node);<br> fastmarching->SetStoppingValue( 150 );<br>
fastmarchingfilter->SetTrialPoints( seeds );<br> fastmarchingfilter->SetSpeedConstant( 1.0 );<br> caster->SetInput(fastmarchingfilter->GetOutput());<br> writer->SetInput( caster->GetOutput() );<br>
writer->SetFileName("fastmarchingoutput.mhd");<br> writer->Update();<br> <br> <br> <br> return 0;<br>}<br clear="all"><br>-- <br>Baris KANDEMIR<br><br>Bogazici University<br>Student of Electrical and Electronics Engineering<br>
<br>