[Insight-users] ThresholdLevelSetSegemntation Filter

mohammed abdel samea mohammed_abdel_samea at yahoo.com
Mon Mar 14 21:13:50 EDT 2011


Hi Dawood,

Thanks very much for your help, the program works well now by changing the pixel 
type to unsigned char. but I don't know why!!.

Furthermore, could you please tell me how can I use multiple seed in my code, 
for example if I'd like to extract 2 Objects in the same output image based on 
Seed1=[200 350 9] and Seed2=[560 980 3].

Thank you again for your help.

Best Regards,
Mohammed


________________________________
From: Dawood Masslawi <masslawi at gmail.com>
To: mohammed_abdel_samea at yahoo.com
Cc: insight-users at itk.org
Sent: Sun, March 13, 2011 6:37:53 AM
Subject: RE: ThresholdLevelSetSegemntation Filter


Hi Mohammed,

1. Try to change your internal pixel type from float to unsigned char or 
unsigned short 

(or RGB if they are colored).

2. Correct, 99.9% :), fast marching segmentation is used to produce the initial 
level set.

The initial distance approximates the distance between the seed points and the 
level set.

3. The threshold is assigned by the user and finding an optimum value depends on 
the

intensity values of the region to be  segmented.

HTH,

Dawood

 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


Dear all,

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
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.



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( 250 );
thresholdSegmentation->SetLowerThreshold( 30 );
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();


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.

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.  

Thirdly, I know that the purpose of ThresholdLevelSet  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?.

Best Regards,
 Mohammed 



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


More information about the Insight-users mailing list