hi all i am doing image segmentation( bone segmentaiton) with fast
marching level sets i have changed a little bit the code which is given
in the examples. the data that i am working is mri data in analyze
format. i have changed it from dicom to analyze. <br>
<br>
sigma=0.98 alfa=-0.64 beta=6 stoptime=32 threshold=40 <br>
but am geting black images no segmented regions.<br>
i have used the insightapplication demos it worked well in that examples so what am i doing wrong i am sending the code attached<br>
<br>
<br>
#include "itkCurvatureAnisotropicDiffusionImageFilter.h"<br>
<br>
#include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"<br>
#include "itkSigmoidImageFilter.h"<br>
<br>
<br>
<br>
<br>
#include "itkImage.h"<br>
#include "itkFastMarchingImageFilter.h"<br>
<br>
#include "itkBinaryThresholdImageFilter.h"<br>
<br>
#include "itkImageFileReader.h"<br>
#include "itkImageFileWriter.h"<br>
<br>
#include "itkRescaleIntensityImageFilter.h"<br>
<br>
<br>
int main( int argc, char *argv[] )<br>
{<br>
if( argc < 21 )<br>
{<br>
std::cerr << "Missing Parameters " << std::endl;<br>
std::cerr << "Usage: " << argv[0];<br>
std::cerr << " inputImage outputImage seedX seedY seedZ seedX2 seedY2 seedZ2";<br>
std::cerr << " seedX3 seedY3 seedZ3 seedX4 seedY4 seedZ4 seedX5 seedY5 seedZ5 ";<br>
std::cerr << " Sigma SigmoidAlpha SigmoidBeta TimeThreshold StoppingValue" << std::endl;<br>
return 1;<br>
}<br>
<br>
<br>
<br>
typedef float InternalPixelType;<br>
const unsigned int Dimension = 3;<br>
typedef itk::Image< InternalPixelType, Dimension > InternalImageType;<br>
<br>
typedef unsigned char OutputPixelType;<br>
typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br>
<br>
<br>
<br>
typedef itk::ImageFileReader< InternalImageType > ReaderType;<br>
typedef itk::ImageFileWriter< OutputImageType > WriterType;<br>
<br>
<br>
<br>
ReaderType::Pointer reader = ReaderType::New();<br>
WriterType::Pointer writer = WriterType::New();<br>
<br>
reader->SetFileName( argv[1] );<br>
writer->SetFileName( argv[2] );<br>
<br>
<br>
<br>
typedef itk::RescaleIntensityImageFilter< <br>
InternalImageType, <br>
OutputImageType > RescaleFilterType;<br>
<br>
<br>
<br>
// Discrete CurvatureAnistropicDiffusionImageFilter<br>
<br>
typedef itk::CurvatureAnisotropicDiffusionImageFilter< <br>
InternalImageType, <br>
InternalImageType > SmoothingFilterType;<br>
<br>
SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New();<br>
smoothing->SetTimeStep( 0.0625 );<br>
smoothing->SetNumberOfIterations( 5 );<br>
smoothing-> SetConductanceParameter( 3 );<br>
smoothing->SetInput( reader->GetOutput() );<br>
smoothing->Update();<br>
<br>
<br>
<br>
RescaleFilterType::Pointer rescaler = RescaleFilterType::New();<br>
rescaler->SetOutputMinimum( 0 );<br>
rescaler->SetOutputMaximum( 255 );<br>
rescaler->SetInput( smoothing->GetOutput() );<br>
<br>
<br>
<br>
<br>
//GradientMagnitudeRecursiveGaussianImageFilter<br>
<br>
typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< <br>
InternalImageType, <br>
InternalImageType > GradientFilterType;<br>
GradientFilterType::Pointer gradientMagnitude = GradientFilterType::New();<br>
<br>
const double sigma = atof( argv[18] );<br>
<br>
gradientMagnitude->SetSigma( sigma );<br>
gradientMagnitude->SetInput( smoothing->GetOutput() );<br>
gradientMagnitude->Update();<br>
<br>
//Sigmoid filter<br>
typedef
itk::SigmoidImageFilter<
<br>
InternalImageType, <br>
InternalImageType > SigmoidFilterType;<br>
<br>
<br>
<br>
SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();<br>
<br>
<br>
sigmoid->SetOutputMinimum( 0.0 );<br>
sigmoid->SetOutputMaximum( 1.0 );<br>
<br>
const double alpha = atof( argv[19] );<br>
const double beta = atof( argv[20] );<br>
sigmoid->SetAlpha( alpha );<br>
sigmoid->SetBeta( beta );<br>
sigmoid->SetInput( gradientMagnitude->GetOutput() );<br>
sigmoid->Update();<br>
<br>
//Fast marching Filter<br>
<br>
typedef itk::FastMarchingImageFilter< InternalImageType, <br>
InternalImageType > FastMarchingFilterType;<br>
<br>
FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();<br>
typedef FastMarchingFilterType::NodeContainer NodeContainer;<br>
typedef
FastMarchingFilterType::NodeType
NodeType;<br>
<br>
NodeContainer::Pointer seeds = NodeContainer::New();<br>
<br>
InternalImageType::IndexType seedPosition;<br>
seedPosition[0] = atoi( argv[3] );<br>
seedPosition[1] = atoi( argv[4] );<br>
seedPosition[2] = atoi( argv[5] );<br>
InternalImageType::IndexType seedPosition2;<br>
seedPosition2[0] = atoi( argv[6] );<br>
seedPosition2[1] = atoi( argv[7] );<br>
seedPosition2[2] = atoi( argv[8] );<br>
InternalImageType::IndexType seedPosition3;<br>
seedPosition3[0] = atoi( argv[9] );<br>
seedPosition3[1] = atoi( argv[10] );<br>
seedPosition3[2] = atoi( argv[11] );<br>
InternalImageType::IndexType seedPosition4;<br>
seedPosition4[0] = atoi( argv[12] );<br>
seedPosition4[1] = atoi( argv[13] );<br>
seedPosition4[2] = atoi( argv[14] );<br>
InternalImageType::IndexType seedPosition5;<br>
seedPosition5[0] = atoi( argv[15] );<br>
seedPosition5[1] = atoi( argv[16] );<br>
seedPosition5[2] = atoi( argv[17] );<br>
// InternalImageType::IndexType seedPosition6;<br>
// seedPosition6[0] = atoi( argv[18] );<br>
//seedPosition6[1] = atoi( argv[19] );<br>
//seedPosition6[2] = atoi( argv[20] );<br>
<br>
NodeType node;<br>
NodeType node2;<br>
NodeType node3;<br>
NodeType node4;<br>
NodeType node5;<br>
//NodeType node6;<br>
const double seedValue = 0.0;<br>
<br>
node.SetValue( seedValue );<br>
node2.SetValue( seedValue );<br>
node3.SetValue( seedValue );<br>
node4.SetValue( seedValue );<br>
node5.SetValue( seedValue );<br>
//node6.SetValue( seedValue );<br>
<br>
node.SetIndex( seedPosition );<br>
node2.SetIndex( seedPosition2 );<br>
node3.SetIndex( seedPosition3 );<br>
node4.SetIndex( seedPosition4 );<br>
node5.SetIndex( seedPosition5 );<br>
//node6.SetIndex( seedPosition6 );<br>
<br>
<br>
seeds->Initialize();<br>
seeds->InsertElement( 0, node );<br>
seeds->InsertElement( 0, node2 );<br>
seeds->InsertElement( 0, node3 );<br>
seeds->InsertElement( 0, node4 );<br>
seeds->InsertElement( 0, node5 );<br>
//seeds->InsertElement( 0, node6 );<br>
<br>
fastMarching->SetTrialPoints( seeds );<br>
<br>
<br>
fastMarching->SetOutputSize( <br>
reader->GetOutput()->GetBufferedRegion().GetSize() );<br>
<br>
<br>
const double stoppingTime = atof( argv[22] );<br>
fastMarching->SetStoppingValue( stoppingTime );<br>
<br>
fastMarching->SetInput( sigmoid->GetOutput() );<br>
fastMarching->Update();<br>
<br>
// Binary Threshold filter<br>
<br>
<br>
typedef itk::BinaryThresholdImageFilter< InternalImageType, <br>
OutputImageType >
ThresholdingFilterType;<br>
ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();<br>
<br>
<br>
const InternalPixelType timeThreshold = atof( argv[21] );<br>
<br>
thresholder->SetLowerThreshold( 0.0 );<br>
thresholder->SetUpperThreshold( timeThreshold );<br>
<br>
thresholder->SetOutsideValue( 0 );<br>
thresholder->SetInsideValue( 1 );<br>
thresholder->SetInput( fastMarching->GetOutput() );<br>
writer->SetInput( thresholder->GetOutput() );<br>
<br>
<br>
try<br>
{<br>
writer->Update();<br>
}<br>
catch( itk::ExceptionObject & excep )<br>
{<br>
std::cerr << "Exception caught !" << std::endl;<br>
std::cerr << excep << std::endl;<br>
}<br>
<br>
<br>
<br>
return 0;<br>
}<br>
<br>
<br>
<br>
<br>
<br>