[Insight-users] ThresholdLevelSetSegemntation Filter

Dawood Masslawi masslawi at gmail.com
Tue Mar 15 17:49:07 EDT 2011


P. S.,
Its probably a good idea to invest a little time in reading the "Spatial Objects" chapter of
the ITK software guide (chapter 5), in particular how to use them in a segmentation.
Good luck,
Dawood

--- On Tue, 3/15/11, Dawood Masslawi <masslawi at gmail.com> wrote:

From: Dawood Masslawi <masslawi at gmail.com>
Subject: Re: ThresholdLevelSetSegemntation Filter
To: "mohammed abdel samea" <mohammed_abdel_samea at yahoo.com>
Cc: insight-users at itk.org
Date: Tuesday, March 15, 2011, 8:27 AM

The reason for your previous setting not to work is that the pixel type float is not supported
for TIFF image format, a list of supported pixel types for different file formats can be found
from the following link,
http://www.vtk.org/Wiki/ITK_File_Formats
The code for feeding multiple seed points to the fast marching filter would look something
like this,

typedef FastMarchingFilterType::NodeContainer           NodeContainer;
typedef FastMarchingFilterType::NodeType              
  NodeType;
NodeContainer::Pointer seeds = NodeContainer::New(); 
InternalImageType::IndexType  seedPosition_1, seedPoistion_2;
 seedPosition_1[0] = 200;
seedPosition_1[1] = 350;
seedPosition_1[2] = 9;

seedPosition_2[0] = 560;
seedPosition_2[1] = 980;
seedPosition_2[2] = 3;

NodeType node_1, node_2;

const double seedValue = 0.0;

node_1.SetValue( seedValue );
node_2.SetValue( seedValue );

node_1.SetIndex( seedPosition_1 );
node_2.SetIndex( seedPosition_2
 );

seeds->Initialize();
seeds->InsertElement( 0, node_1 );
seeds->InsertElement( 0, node_2 );

fastMarching->SetTrialPoints(  seeds  );

As for segmenting multiple objects, if the ThresholdSegmentationLevelSetImageFilter didn't
work try other level set methods (e.g. GeodesicActiveContourLevelSetImageFilter).
Regards,
Dawood


--- On Mon, 3/14/11, mohammed abdel samea <mohammed_abdel_samea at yahoo.com> wrote:

From: mohammed abdel samea <mohammed_abdel_samea at yahoo.com>
Subject: Re: ThresholdLevelSetSegemntation Filter
To:
 "Dawood Masslawi" <masslawi at gmail.com>
Cc: insight-users at itk.org
Date: Monday, March 14, 2011, 9:13 PM

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/20110315/5e4b8639/attachment.htm>


More information about the Insight-users mailing list