<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt">Dear all,<br>
<br>
Actually the code that is shown in this message for you is used for segment a 3D image
based on Threshold Level Set Segmentation Filter, what I did is just
copy this code from
Examples/Segmentation/ThresholdSegmentationLevelSetImageFilter.cxx<br>I did it adjustable for my image. which means: the seed point position I used is completely inside the ROI, file is the file name of my input image it just 1024 x 1024 x 2 gray scale tif image for testing, aaa.tif is the output image, and [30, 50] are the lower and upper threshold interval.<br><br><br><br>typedef&nbsp;&nbsp; float&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InternalPixelType;<br>const&nbsp;&nbsp;&nbsp;&nbsp; unsigned int&nbsp;&nbsp;&nbsp; Dimension = 3;<br>typedef itk::Image&lt; InternalPixelType, Dimension &gt;&nbsp; InternalImageType;<br>typedef unsigned char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OutputPixelType;<br>typedef itk::Image&lt; OutputPixelType, Dimension &gt; OutputImageType;<br>typedef
 itk::BinaryThresholdImageFilter&lt;InternalImageType,
 OutputImageType&gt; ThresholdingFilterType;<br>ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>thresholder-&gt;SetLowerThreshold( -1000.0 );<br>thresholder-&gt;SetUpperThreshold(&nbsp;&nbsp;&nbsp;&nbsp; 0.0 );<br>thresholder-&gt;SetOutsideValue(&nbsp; 0&nbsp; );<br>thresholder-&gt;SetInsideValue(&nbsp; 255 );<br>typedef&nbsp; itk::ImageFileReader&lt; InternalImageType &gt; ReaderType;<br>typedef&nbsp; itk::ImageFileWriter&lt;&nbsp; OutputImageType&nbsp; &gt; WriterType;<br>ReaderType::Pointer reader = ReaderType::New();<br>WriterType::Pointer writer = WriterType::New();<br>reader-&gt;SetFileName( file );<br>reader-&gt;Update();<br>writer-&gt;SetFileName( "aaa.tif" );<br>typedef&nbsp; itk::FastMarchingImageFilter&lt; InternalImageType, InternalImageType &gt;&nbsp;
 FastMarchingFilterType;<br>FastMarchingFilterType::Pointer&nbsp; fastMarching = FastMarchingFilterType::New();<br>const InternalImageType * inputImage = reader-&gt;GetOutput();<br>fastMarching-&gt;SetOutputRegion( inputImage-&gt;GetBufferedRegion() );<br>fastMarching-&gt;SetOutputSpacing( inputImage-&gt;GetSpacing() );<br>fastMarching-&gt;SetOutputOrigin( inputImage-&gt;GetOrigin() );<br>fastMarching-&gt;SetOutputDirection( inputImage-&gt;GetDirection() );<br>typedef&nbsp; itk::ThresholdSegmentationLevelSetImageFilter&lt;
InternalImageType, InternalImageType &gt;
ThresholdSegmentationLevelSetImageFilterType;<br>ThresholdSegmentationLevelSetImageFilterType::Pointer
thresholdSegmentation =&nbsp;
ThresholdSegmentationLevelSetImageFilterType::New();<br>thresholdSegmentation-&gt;SetPropagationScaling( 1.0 );<br>thresholdSegmentation-&gt;SetCurvatureScaling( 1.0 );<br>thresholdSegmentation-&gt;SetMaximumRMSError( 0.02 );<br>thresholdSegmentation-&gt;SetNumberOfIterations( 1200 );<br>thresholdSegmentation-&gt;SetUpperThreshold( 250 );<br>thresholdSegmentation-&gt;SetLowerThreshold( 30 );<br>thresholdSegmentation-&gt;SetIsoSurfaceValue(0.0);<br>typedef FastMarchingFilterType::NodeContainer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NodeContainer;<br>typedef FastMarchingFilterType::NodeType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NodeType;<br>NodeContainer::Pointer seeds = NodeContainer::New();<br>InternalImageType::IndexType&nbsp; seedPosition;<br>seedPosition[0] = 358;<br>seedPosition[1] = 529;<br>seedPosition[2] = 2;<br>const double initialDistance = 5.0;<br>NodeType node;<br>const
 double seedValue = - initialDistance;<br>node.SetValue( seedValue );<br>node.SetIndex( seedPosition );<br>seeds-&gt;Initialize();<br>seeds-&gt;InsertElement( 0, node );<br>fastMarching-&gt;SetTrialPoints(&nbsp; seeds&nbsp; );<br>fastMarching-&gt;SetSpeedConstant( 1.0 );<br>fastMarching-&gt;Update();<br>thresholdSegmentation-&gt;SetInput( fastMarching-&gt;GetOutput() );<br>thresholdSegmentation-&gt;SetFeatureImage( reader-&gt;GetOutput() );<br>thresholdSegmentation-&gt;Update();<br>thresholder-&gt;SetInput( thresholdSegmentation-&gt;GetOutput() );<br>thresholder-&gt;Update();<br>writer-&gt;SetInput( thresholder-&gt;GetOutput() );<br>writer-&gt;Update();<br><br><br>Firstly, There is no error messange. However, the output image "aaa.tif" is black. so I don't have interperation about what's the error. I just want to make it works. your help is really appericiated about this.<br><br>Secondly, the purpose of using Fast Marching segmentation is generate the
 initial countor based on the seed point to use it as the countor image (or the zero level set image) to use it as input to the ThresholdLevelSet Filter. is it right?. Also, I cann't understand what is the purpose of initialDistance for the fast marching. I'm sorry I'm not familar with Level Set and ITK documentation is not enough for me to understand everything.&nbsp; <br><br>Thirdly, I know that the purpose of ThresholdLevelSet&nbsp; is find the optimal lower and upper thresholds for segment the image using Level Set which this filter is the extension of the Connected Threshold method. is it right?. How is it?.<br><br>Best Regards,<br>&nbsp;Mohammed<br></div><br>

      </body></html>