<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>I've tried to segment a 3D image using Threshold Level Set Segmentation filter.<br>I used the following code:<br><br><br>typedef&nbsp;&nbsp; float&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InternalPixelType;<br>&nbsp; const&nbsp;&nbsp;&nbsp;&nbsp; unsigned int&nbsp;&nbsp;&nbsp; Dimension = 3;<br>&nbsp; typedef itk::Image&lt; InternalPixelType, Dimension &gt;&nbsp; InternalImageType;<br>&nbsp;&nbsp; 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>&nbsp; typedef itk::Image&lt; OutputPixelType, Dimension &gt; OutputImageType;<br>&nbsp; typedef itk::BinaryThresholdImageFilter&lt;InternalImageType,
 OutputImageType&gt; ThresholdingFilterType;<br>&nbsp; &nbsp; ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp; thresholder-&gt;SetLowerThreshold( -1000.0 );<br>&nbsp; thresholder-&gt;SetUpperThreshold(&nbsp;&nbsp;&nbsp;&nbsp; 0.0 );<br>&nbsp; thresholder-&gt;SetOutsideValue(&nbsp; 0&nbsp; );<br>&nbsp; thresholder-&gt;SetInsideValue(&nbsp; 255 );<br>&nbsp; typedef&nbsp; itk::ImageFileReader&lt; InternalImageType &gt; ReaderType;<br>&nbsp; typedef&nbsp; itk::ImageFileWriter&lt;&nbsp; OutputImageType&nbsp; &gt; WriterType;<br>&nbsp; ReaderType::Pointer reader = ReaderType::New();<br>&nbsp; WriterType::Pointer writer = WriterType::New();<br>&nbsp; reader-&gt;SetFileName( file );<br>&nbsp; reader-&gt;Update();<br>&nbsp; writer-&gt;SetFileName( "aaa.tif" );<br>&nbsp; typedef&nbsp; itk::FastMarchingImageFilter&lt; InternalImageType, InternalImageType &gt;&nbsp;
 FastMarchingFilterType;<br>&nbsp; FastMarchingFilterType::Pointer&nbsp; fastMarching = FastMarchingFilterType::New();<br>&nbsp;&nbsp;&nbsp;&nbsp; const InternalImageType * inputImage = reader-&gt;GetOutput();<br>&nbsp;&nbsp;&nbsp; fastMarching-&gt;SetOutputRegion( inputImage-&gt;GetBufferedRegion() );<br>&nbsp;&nbsp;&nbsp; fastMarching-&gt;SetOutputSpacing( inputImage-&gt;GetSpacing() );<br>&nbsp;&nbsp;&nbsp; fastMarching-&gt;SetOutputOrigin( inputImage-&gt;GetOrigin() );<br>&nbsp;&nbsp;&nbsp; fastMarching-&gt;SetOutputDirection( inputImage-&gt;GetDirection() );<br>&nbsp; typedef&nbsp; itk::ThresholdSegmentationLevelSetImageFilter&lt; InternalImageType, InternalImageType &gt; ThresholdSegmentationLevelSetImageFilterType;<br>&nbsp; ThresholdSegmentationLevelSetImageFilterType::Pointer thresholdSegmentation =&nbsp; ThresholdSegmentationLevelSetImageFilterType::New();<br>&nbsp; thresholdSegmentation-&gt;SetPropagationScaling( 1.0 );<br>&nbsp;&nbsp;&nbsp;
 thresholdSegmentation-&gt;SetCurvatureScaling( 1.0 );<br>&nbsp;&nbsp;&nbsp; thresholdSegmentation-&gt;SetMaximumRMSError( 0.02 );<br>&nbsp;&nbsp;&nbsp; thresholdSegmentation-&gt;SetNumberOfIterations( 1200 );<br>&nbsp; thresholdSegmentation-&gt;SetUpperThreshold( 30 );<br>&nbsp; thresholdSegmentation-&gt;SetLowerThreshold( 250 );<br>&nbsp; thresholdSegmentation-&gt;SetIsoSurfaceValue(0.0);<br>&nbsp;typedef FastMarchingFilterType::NodeContainer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NodeContainer;<br>&nbsp; typedef FastMarchingFilterType::NodeType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NodeType;<br>&nbsp; NodeContainer::Pointer seeds = NodeContainer::New();<br>&nbsp; InternalImageType::IndexType&nbsp; seedPosition;<br>&nbsp; seedPosition[0] = 358;<br>&nbsp; seedPosition[1] = 529;<br>&nbsp;&nbsp;&nbsp; seedPosition[2] = 2;<br>&nbsp; const double initialDistance = 5.0;<br>&nbsp;
 NodeType node;<br>&nbsp; const double seedValue = - initialDistance;<br>&nbsp; node.SetValue( seedValue );<br>&nbsp; node.SetIndex( seedPosition );<br>&nbsp; seeds-&gt;Initialize();<br>&nbsp; seeds-&gt;InsertElement( 0, node );<br>&nbsp; fastMarching-&gt;SetTrialPoints(&nbsp; seeds&nbsp; );<br>&nbsp; fastMarching-&gt;SetSpeedConstant( 1.0 );<br>&nbsp;fastMarching-&gt;Update();<br>&nbsp; thresholdSegmentation-&gt;SetInput( fastMarching-&gt;GetOutput() );<br>&nbsp; thresholdSegmentation-&gt;SetFeatureImage( reader-&gt;GetOutput() );<br>&nbsp; thresholdSegmentation-&gt;Update();<br>&nbsp; thresholder-&gt;SetInput( thresholdSegmentation-&gt;GetOutput() );<br>&nbsp;thresholder-&gt;Update();<br>&nbsp; writer-&gt;SetInput( thresholder-&gt;GetOutput() );<br>&nbsp; writer-&gt;Update();<br><br><br>There is no error messange. However, the output image "aaa.tif" is black.<br>note the seed point I used is completely inside the object that I'd like to segment.
 <br>Why the output image is black!. your help is really appericiated for making this code work properly.<br><br>Best Regards,<br>&nbsp;Mohammed<br></div><br>

      </body></html>