[Insight-users] Threshold Level Set Segmentation

mohammed abdel samea mohammed_abdel_samea at yahoo.com
Fri Mar 11 03:00:01 EST 2011


Dear all,

I've tried to segment a 3D image using Threshold Level Set Segmentation filter.
I used the following code:


typedef   float           InternalPixelType;
  const     unsigned int    Dimension = 3;
  typedef itk::Image< InternalPixelType, Dimension >  InternalImageType;
   typedef unsigned char                            OutputPixelType;
  typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
  typedef itk::BinaryThresholdImageFilter<InternalImageType, OutputImageType> 
ThresholdingFilterType;
    ThresholdingFilterType::Pointer thresholder = 
ThresholdingFilterType::New();      

  thresholder->SetLowerThreshold( -1000.0 );
  thresholder->SetUpperThreshold(     0.0 );
  thresholder->SetOutsideValue(  0  );
  thresholder->SetInsideValue(  255 );
  typedef  itk::ImageFileReader< InternalImageType > ReaderType;
  typedef  itk::ImageFileWriter<  OutputImageType  > WriterType;
  ReaderType::Pointer reader = ReaderType::New();
  WriterType::Pointer writer = WriterType::New();
  reader->SetFileName( file );
  reader->Update();
  writer->SetFileName( "aaa.tif" );
  typedef  itk::FastMarchingImageFilter< InternalImageType, InternalImageType >  
FastMarchingFilterType;
  FastMarchingFilterType::Pointer  fastMarching = FastMarchingFilterType::New();
     const InternalImageType * inputImage = reader->GetOutput();
    fastMarching->SetOutputRegion( inputImage->GetBufferedRegion() );
    fastMarching->SetOutputSpacing( inputImage->GetSpacing() );
    fastMarching->SetOutputOrigin( inputImage->GetOrigin() );
    fastMarching->SetOutputDirection( inputImage->GetDirection() );
  typedef  itk::ThresholdSegmentationLevelSetImageFilter< InternalImageType, 
InternalImageType > ThresholdSegmentationLevelSetImageFilterType;
  ThresholdSegmentationLevelSetImageFilterType::Pointer thresholdSegmentation =  
ThresholdSegmentationLevelSetImageFilterType::New();
  thresholdSegmentation->SetPropagationScaling( 1.0 );
    thresholdSegmentation->SetCurvatureScaling( 1.0 );
    thresholdSegmentation->SetMaximumRMSError( 0.02 );
    thresholdSegmentation->SetNumberOfIterations( 1200 );
  thresholdSegmentation->SetUpperThreshold( 30 );
  thresholdSegmentation->SetLowerThreshold( 250 );
  thresholdSegmentation->SetIsoSurfaceValue(0.0);
 typedef FastMarchingFilterType::NodeContainer           NodeContainer;
  typedef FastMarchingFilterType::NodeType                NodeType;
  NodeContainer::Pointer seeds = NodeContainer::New();
  InternalImageType::IndexType  seedPosition;
  seedPosition[0] = 358;
  seedPosition[1] = 529;
    seedPosition[2] = 2;
  const double initialDistance = 5.0;
  NodeType node;
  const double seedValue = - initialDistance;
  node.SetValue( seedValue );
  node.SetIndex( seedPosition );
  seeds->Initialize();
  seeds->InsertElement( 0, node );
  fastMarching->SetTrialPoints(  seeds  );
  fastMarching->SetSpeedConstant( 1.0 );
 fastMarching->Update();
  thresholdSegmentation->SetInput( fastMarching->GetOutput() );
  thresholdSegmentation->SetFeatureImage( reader->GetOutput() );
  thresholdSegmentation->Update();
  thresholder->SetInput( thresholdSegmentation->GetOutput() );
 thresholder->Update();
  writer->SetInput( thresholder->GetOutput() );
  writer->Update();


There is no error messange. However, the output image "aaa.tif" is black.
note the seed point I used is completely inside the object that I'd like to 
segment. 

Why the output image is black!. your help is really appericiated for making this 
code work properly.

Best Regards,
 Mohammed



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110311/e0533647/attachment.htm>


More information about the Insight-users mailing list