<DIV>Hi,</DIV> <DIV>I modified FastMarchingImageFilter.cxx that is found in Examples\Segmentation to work on a 3D analyze format image. After compilation, I executed it from the command line:</DIV> <DIV> </DIV><FONT size=2> <DIV>FM_Filter3D.exe mri4itk.hdr mri4itkResult.hdr <FONT size=2></DIV> <DIV>1.25 -8.0 75.0 10 15 </DIV> <DIV>108 125 1 110 125 5 112 124 10 113 124 15 113 123 20 107 130 25 94 136 32</DIV> <DIV> </DIV> <DIV>The second line has values for sigma, alpha, beta, threshold and stopping time</DIV> <DIV>The third line contains indices (x,y,z) for a set of 7 points. All three lines were concatenated into one when running the program. The segmentation results don't look good. The binary image contains a large white spot in each slice. I am trying to segment the right artery which appears as a white spot on the right side in the input image. The text of my program is given below. I tried to attach the image (mri4itk.hdr, mri4itk.img) to this
email, but the email bounced. The size is approximately 3 MB. Can I send the images somehow? </DIV> <DIV> </DIV> <DIV>Thanks,</DIV> <DIV>Vijay</DIV> <DIV> </DIV><FONT color=#0000ff size=2> <DIV>#include</FONT><FONT size=2> </FONT><FONT color=#800000 size=2>"itkCurvatureAnisotropicDiffusionImageFilter.h"</DIV></FONT><FONT color=#0000ff size=2> <DIV>#include</FONT><FONT size=2> </FONT><FONT color=#800000 size=2>"itkGradientMagnitudeRecursiveGaussianImageFilter.h"</DIV></FONT><FONT color=#0000ff size=2> <DIV>#include</FONT><FONT size=2> </FONT><FONT color=#800000 size=2>"itkSigmoidImageFilter.h"</DIV></FONT><FONT color=#0000ff size=2> <DIV>#include</FONT><FONT size=2> </FONT><FONT color=#800000 size=2>"itkImage.h"</DIV></FONT><FONT color=#0000ff size=2> <DIV>#include</FONT><FONT size=2> </FONT><FONT color=#800000 size=2>"itkFastMarchingImageFilter.h"</DIV></FONT><FONT color=#0000ff size=2> <DIV>#include</FONT><FONT size=2> </FONT><FONT color=#800000
size=2>"itkBinaryThresholdImageFilter.h"</DIV></FONT><FONT color=#0000ff size=2> <DIV>#include</FONT><FONT size=2> </FONT><FONT color=#800000 size=2>"itkImageFileReader.h"</DIV></FONT><FONT color=#0000ff size=2> <DIV>#include</FONT><FONT size=2> </FONT><FONT color=#800000 size=2>"itkImageFileWriter.h"</DIV></FONT><FONT color=#0000ff size=2> <DIV>#include</FONT><FONT size=2> </FONT><FONT color=#800000 size=2>"itkRescaleIntensityImageFilter.h"</DIV></FONT><FONT color=#0000ff size=2> <DIV>int</FONT><FONT size=2> main( </FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> argc, </FONT><FONT color=#0000ff size=2>char</FONT><FONT size=2> *argv[] )</DIV> <DIV>{</DIV> <DIV></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2>( argc < 11 ) {</DIV> <DIV>std::cerr << </FONT><FONT color=#800000 size=2>"Missing Parameters "</FONT><FONT size=2> << std::endl;</DIV> <DIV>std::cerr << </FONT><FONT color=#800000 size=2>"Usage: "</FONT><FONT size=2>
<< argv[0];</DIV> <DIV>std::cerr << </FONT><FONT color=#800000 size=2>" inputImage outputImage"</FONT><FONT size=2>;</DIV> <DIV>std::cerr << </FONT><FONT color=#800000 size=2>" Sigma SigmoidAlpha SigmoidBeta TimeThreshold StoppingValue seedX seedY seedZ"</FONT><FONT size=2> << std::endl;</DIV> <DIV></FONT><FONT color=#0000ff size=2>return</FONT><FONT size=2> 1;</DIV> <DIV>}</DIV> <DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>float</FONT><FONT size=2> InternalPixelType;</DIV> <DIV></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>unsigned</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> Dimension = 3;</DIV> <DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::Image< InternalPixelType, Dimension > InternalImageType;</DIV> <DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2>
</FONT><FONT color=#0000ff size=2>unsigned</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>char</FONT><FONT size=2> OutputPixelType;</DIV> <DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::Image< OutputPixelType, Dimension > OutputImageType;</DIV> <DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::BinaryThresholdImageFilter< InternalImageType, </DIV> <DIV>OutputImageType > ThresholdingFilterType;</DIV> <DIV>ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();</DIV> <DIV></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> InternalPixelType timeThreshold = atof( argv[6] );</DIV> <DIV></DIV> <DIV>thresholder->SetLowerThreshold( 0.0 );</DIV> <DIV>thresholder->SetUpperThreshold( timeThreshold );</DIV> <DIV>thresholder->SetOutsideValue( 0 );</DIV> <DIV>thresholder->SetInsideValue( 255 );</DIV> <DIV></DIV> <DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT
size=2> itk::ImageFileReader< InternalImageType > ReaderType;</DIV> <DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::ImageFileWriter< OutputImageType > WriterType;</DIV> <DIV></DIV> <DIV>ReaderType::Pointer reader = ReaderType::New();</DIV> <DIV>WriterType::Pointer writer = WriterType::New();</DIV> <DIV>reader->SetFileName( argv[1] );</DIV> <DIV>writer->SetFileName( argv[2] );</DIV> <DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::RescaleIntensityImageFilter< </DIV> <DIV>InternalImageType, </DIV> <DIV>OutputImageType > CastFilterType;</DIV> <DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::CurvatureAnisotropicDiffusionImageFilter< </DIV> <DIV>InternalImageType, </DIV> <DIV>InternalImageType > SmoothingFilterType;</DIV> <DIV>SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New();</DIV> <DIV></DIV> <DIV></FONT><FONT color=#0000ff
size=2>typedef</FONT><FONT size=2> itk::GradientMagnitudeRecursiveGaussianImageFilter< </DIV> <DIV>InternalImageType, </DIV> <DIV>InternalImageType > GradientFilterType;</DIV> <DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::SigmoidImageFilter< </DIV> <DIV>InternalImageType, </DIV> <DIV>InternalImageType > SigmoidFilterType;</DIV> <DIV></DIV> <DIV>GradientFilterType::Pointer gradientMagnitude = GradientFilterType::New();</DIV> <DIV>SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();</DIV> <DIV>sigmoid->SetOutputMinimum( 0.0 );</DIV> <DIV>sigmoid->SetOutputMaximum( 1.0 );</DIV> <DIV></DIV> <DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::FastMarchingImageFilter< InternalImageType, </DIV> <DIV>InternalImageType > FastMarchingFilterType;</DIV> <DIV>FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();</DIV> <DIV></DIV> <DIV>smoothing->SetInput(
reader->GetOutput() );</DIV> <DIV>gradientMagnitude->SetInput( smoothing->GetOutput() );</DIV> <DIV>sigmoid->SetInput( gradientMagnitude->GetOutput() );</DIV> <DIV>fastMarching->SetInput( sigmoid->GetOutput() );</DIV> <DIV>thresholder->SetInput( fastMarching->GetOutput() );</DIV> <DIV>writer->SetInput( thresholder->GetOutput() );</DIV> <DIV>smoothing->SetTimeStep( 0.0625 );</DIV> <DIV>smoothing->SetNumberOfIterations( 5 );</DIV> <DIV>smoothing->SetConductanceParameter( 9.0 );</DIV> <DIV></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> sigma = atof( argv[3] );</DIV> <DIV>gradientMagnitude->SetSigma( sigma );</DIV> <DIV></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> alpha = atof( argv[4] );</DIV> <DIV></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT
color=#0000ff size=2>double</FONT><FONT size=2> beta = atof( argv[5] );</DIV> <DIV>sigmoid->SetAlpha( alpha );</DIV> <DIV>sigmoid->SetBeta( beta );</DIV> <DIV></DIV> <DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> FastMarchingFilterType::NodeContainer NodeContainer;</DIV> <DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> FastMarchingFilterType::NodeType NodeType;</DIV> <DIV>NodeContainer::Pointer seeds = NodeContainer::New();</DIV> <DIV></DIV> <DIV>InternalImageType::IndexType seedPosition1;</DIV> <DIV>InternalImageType::IndexType seedPosition2;</DIV> <DIV>InternalImageType::IndexType seedPosition3;</DIV> <DIV>InternalImageType::IndexType seedPosition4;</DIV> <DIV>InternalImageType::IndexType seedPosition5;</DIV> <DIV>InternalImageType::IndexType seedPosition6;</DIV> <DIV>InternalImageType::IndexType seedPosition7;</DIV></FONT><FONT color=#008000 size=2> <DIV> </DIV></FONT><FONT size=2> <DIV>seedPosition1[0] =
atoi( argv[8] );</DIV> <DIV>seedPosition1[1] = atoi( argv[9] );</DIV> <DIV>seedPosition1[2] = atoi( argv[10] );</DIV> <DIV>seedPosition2[0] = atoi( argv[11] );</DIV> <DIV>seedPosition2[1] = atoi( argv[12] );</DIV> <DIV>seedPosition2[2] = atoi( argv[13] );</DIV> <DIV>seedPosition3[0] = atoi( argv[14] );</DIV> <DIV>seedPosition3[1] = atoi( argv[15] );</DIV> <DIV>seedPosition3[2] = atoi( argv[16] );</DIV> <DIV>seedPosition4[0] = atoi( argv[17] );</DIV> <DIV>seedPosition4[1] = atoi( argv[18] );</DIV> <DIV>seedPosition4[2] = atoi( argv[19] );</DIV> <DIV>seedPosition5[0] = atoi( argv[20] );</DIV> <DIV>seedPosition5[1] = atoi( argv[21] );</DIV> <DIV>seedPosition5[2] = atoi( argv[22] );</DIV> <DIV>seedPosition6[0] = atoi( argv[23] );</DIV> <DIV>seedPosition6[1] = atoi( argv[24] );</DIV> <DIV>seedPosition6[2] = atoi( argv[25] );</DIV> <DIV>seedPosition7[0] = atoi( argv[26] );</DIV> <DIV>seedPosition7[1] = atoi( argv[27] );</DIV> <DIV>seedPosition7[2] = atoi(
argv[28] );</DIV> <DIV>NodeType seed1;</DIV> <DIV>NodeType seed2;</DIV> <DIV>NodeType seed3;</DIV> <DIV>NodeType seed4;</DIV> <DIV>NodeType seed5;</DIV> <DIV>NodeType seed6;</DIV> <DIV>NodeType seed7;</DIV></FONT><FONT color=#008000 size=2></FONT><FONT size=2> <DIV></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> seedValue = 0.0;</DIV> <DIV>seed1.SetValue( seedValue );</DIV> <DIV>seed1.SetIndex( seedPosition1 );</DIV> <DIV>seed2.SetValue( seedValue );</DIV> <DIV>seed2.SetIndex( seedPosition2 );</DIV></FONT><FONT color=#008000 size=2></FONT><FONT size=2> <DIV>seed3.SetValue( seedValue );</DIV> <DIV>seed3.SetIndex( seedPosition3 );</DIV></FONT><FONT color=#008000 size=2></FONT><FONT size=2> <DIV>seed3.SetValue( seedValue );</DIV> <DIV>seed3.SetIndex( seedPosition4 );</DIV></FONT><FONT color=#008000 size=2></FONT><FONT size=2> <DIV>seed3.SetValue( seedValue );</DIV> <DIV>seed3.SetIndex(
seedPosition5 );</DIV></FONT><FONT color=#008000 size=2></FONT><FONT size=2> <DIV>seed3.SetValue( seedValue );</DIV> <DIV>seed3.SetIndex( seedPosition6 );</DIV></FONT><FONT color=#008000 size=2></FONT><FONT size=2> <DIV>seed3.SetValue( seedValue );</DIV> <DIV>seed3.SetIndex( seedPosition7 );</DIV> <DIV></DIV> <DIV>seeds->Initialize();</DIV> <DIV>seeds->InsertElement( 0, seed1 );</DIV> <DIV>seeds->InsertElement( 1, seed2 );</DIV> <DIV>seeds->InsertElement( 2, seed3 );</DIV> <DIV>seeds->InsertElement( 3, seed4 );</DIV> <DIV>seeds->InsertElement( 4, seed5 );</DIV> <DIV>seeds->InsertElement( 5, seed4 );</DIV> <DIV>seeds->InsertElement( 6, seed5 );</DIV> <DIV>fastMarching->SetTrialPoints( seeds );</DIV> <DIV></DIV> <DIV>CastFilterType::Pointer caster1 = CastFilterType::New();</DIV> <DIV>CastFilterType::Pointer caster2 = CastFilterType::New();</DIV> <DIV>CastFilterType::Pointer caster3 = CastFilterType::New();</DIV>
<DIV>CastFilterType::Pointer caster4 = CastFilterType::New();</DIV> <DIV>WriterType::Pointer writer1 = WriterType::New();</DIV> <DIV>WriterType::Pointer writer2 = WriterType::New();</DIV> <DIV>WriterType::Pointer writer3 = WriterType::New();</DIV> <DIV>WriterType::Pointer writer4 = WriterType::New();</DIV> <DIV>caster1->SetInput( smoothing->GetOutput() );</DIV> <DIV>writer1->SetInput( caster1->GetOutput() );</DIV> <DIV>writer1->SetFileName(</FONT><FONT color=#800000 size=2>"FastMarchingFilterOutput1.hdr"</FONT><FONT size=2>);</DIV> <DIV>caster1->SetOutputMinimum( 0 );</DIV> <DIV>caster1->SetOutputMaximum( 255 );</DIV> <DIV>writer1->Update();</DIV> <DIV>caster2->SetInput( gradientMagnitude->GetOutput() );</DIV> <DIV>writer2->SetInput( caster2->GetOutput() );</DIV> <DIV>writer2->SetFileName(</FONT><FONT color=#800000 size=2>"FastMarchingFilterOutput2.hdr"</FONT><FONT size=2>);</DIV> <DIV>caster2->SetOutputMinimum( 0
);</DIV> <DIV>caster2->SetOutputMaximum( 255 );</DIV> <DIV>writer2->Update();</DIV> <DIV>caster3->SetInput( sigmoid->GetOutput() );</DIV> <DIV>writer3->SetInput( caster3->GetOutput() );</DIV> <DIV>writer3->SetFileName(</FONT><FONT color=#800000 size=2>"FastMarchingFilterOutput3.hdr"</FONT><FONT size=2>);</DIV> <DIV>caster3->SetOutputMinimum( 0 );</DIV> <DIV>caster3->SetOutputMaximum( 255 );</DIV> <DIV>writer3->Update();</DIV> <DIV>caster4->SetInput( fastMarching->GetOutput() );</DIV> <DIV>writer4->SetInput( caster4->GetOutput() );</DIV> <DIV>writer4->SetFileName(</FONT><FONT color=#800000 size=2>"FastMarchingFilterOutput4.hdr"</FONT><FONT size=2>);</DIV> <DIV>caster4->SetOutputMinimum( 0 );</DIV> <DIV>caster4->SetOutputMaximum( 255 );</DIV> <DIV>fastMarching->SetOutputSize( </DIV> <DIV>reader->GetOutput()->GetBufferedRegion().GetSize() );</DIV> <DIV></FONT><FONT color=#0000ff
size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> stoppingTime = atof( argv[7] );</DIV> <DIV>fastMarching->SetStoppingValue( stoppingTime );</DIV> <DIV></DIV> <DIV></FONT><FONT color=#0000ff size=2>try</DIV></FONT><FONT size=2> <DIV>{</DIV> <DIV>writer->Update();</DIV> <DIV>}</DIV> <DIV></FONT><FONT color=#0000ff size=2>catch</FONT><FONT size=2>( itk::ExceptionObject & excep )</DIV> <DIV>{</DIV> <DIV>std::cerr << </FONT><FONT color=#800000 size=2>"Exception caught !"</FONT><FONT size=2> << std::endl;</DIV> <DIV>std::cerr << excep << std::endl;</DIV> <DIV>}</DIV> <DIV>writer4->Update();</DIV> <DIV></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::ImageFileWriter< InternalImageType > InternalWriterType;</DIV> <DIV>InternalWriterType::Pointer mapWriter = InternalWriterType::New();</DIV> <DIV>mapWriter->SetInput( fastMarching->GetOutput() );</DIV>
<DIV>mapWriter->SetFileName(</FONT><FONT color=#800000 size=2>"FastMarchingFilterOutput4.mha"</FONT><FONT size=2>);</DIV> <DIV>mapWriter->Update();</DIV> <DIV>InternalWriterType::Pointer speedWriter = InternalWriterType::New();</DIV> <DIV>speedWriter->SetInput( sigmoid->GetOutput() );</DIV> <DIV>speedWriter->SetFileName(</FONT><FONT color=#800000 size=2>"FastMarchingFilterOutput3.mha"</FONT><FONT size=2>);</DIV> <DIV>speedWriter->Update();</DIV> <DIV>InternalWriterType::Pointer gradientWriter = InternalWriterType::New();</DIV> <DIV>gradientWriter->SetInput( gradientMagnitude->GetOutput() );</DIV> <DIV>gradientWriter->SetFileName(</FONT><FONT color=#800000 size=2>"FastMarchingFilterOutput2.mha"</FONT><FONT size=2>);</DIV> <DIV>gradientWriter->Update();</DIV> <DIV></FONT><FONT color=#0000ff size=2>return</FONT><FONT size=2> 0;</DIV> <DIV>}</DIV></FONT><FONT face=Arial size=2></FONT></FONT></FONT><p> 
<hr size=1>Ahhh...imagining that irresistible "new car" smell?<br> Check out
<a href="http://us.rd.yahoo.com/evt=48245/*http://autos.yahoo.com/new_cars.html;_ylc=X3oDMTE1YW1jcXJ2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDbmV3LWNhcnM-">new cars at Yahoo! Autos.</a>