<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">P. S.,<div><br></div><div>Its probably a good idea to invest a little time in reading the "Spatial Objects" chapter of</div><div><br></div><div>the ITK software guide (chapter 5), in particular how to use them in a segmentation.</div><div><br></div><div>Good luck,</div><div><br></div><div>Dawood<br><br>--- On <b>Tue, 3/15/11, Dawood Masslawi <i><davoud_zzz@yahoo.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Dawood Masslawi <davoud_zzz@yahoo.com><br>Subject: Re: ThresholdLevelSetSegemntation Filter<br>To: "mohammed abdel samea" <mohammed_abdel_samea@yahoo.com><br>Cc: insight-users@itk.org<br>Date: Tuesday, March 15, 2011, 8:27 AM<br><br><div id="yiv1632450515"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top"
style="font:inherit;">The reason for your previous setting not to work is that the pixel type float is not supported<div><br></div><div>for TIFF image format, a list of supported pixel types for different file formats can be found</div><div><br></div><div>from the following link,</div><div><br></div><div><a rel="nofollow" target="_blank" href="http://www.vtk.org/Wiki/ITK_File_Formats">http://www.vtk.org/Wiki/ITK_File_Formats</a></div><div><br></div><div><a rel="nofollow" target="_blank" href="http://www.vtk.org/Wiki/ITK_File_Formats"></a>The code for feeding multiple seed points to the fast marching filter would look something</div><div><br></div><div>like this,</div><div><br></div><div><br></div><div><div>typedef FastMarchingFilterType::NodeContainer NodeContainer;</div><div><br></div><div>typedef FastMarchingFilterType::NodeType
NodeType;</div><div><br></div><div>NodeContainer::Pointer seeds = NodeContainer::New();</div><div> </div><div><br></div><div>InternalImageType::IndexType seedPosition_1, seedPoistion_2;</div><div><br></div><div> </div><div>seedPosition_1[0] = 200;</div><div><br></div><div>seedPosition_1[1] = 350;</div><div><br></div><div>seedPosition_1[2] = 9;</div><div><br></div><div><br></div><div>seedPosition_2[0] = 560;</div><div><br></div><div>seedPosition_2[1] = 980;</div><div><br></div><div>seedPosition_2[2] = 3;</div><div><br></div><div><br></div><div>NodeType node_1, node_2;</div><div><br></div><div><br></div><div>const double seedValue = 0.0;</div><div><br></div><div><br></div><div>node_1.SetValue( seedValue );</div><div><br></div><div>node_2.SetValue( seedValue );</div><div><br></div><div><br></div><div>node_1.SetIndex( seedPosition_1 );</div><div><br></div><div>node_2.SetIndex( seedPosition_2
);</div><div><br></div><div><br></div><div>seeds->Initialize();</div><div><br></div><div>seeds->InsertElement( 0, node_1 );</div><div><br></div><div>seeds->InsertElement( 0, node_2 );</div><div><br></div><div><br></div><div>fastMarching->SetTrialPoints( seeds );</div><div><br></div><div><br></div><div>As for segmenting multiple objects, if the ThresholdSegmentationLevelSetImageFilter didn't</div><div><br></div><div>work try other level set methods (e.g. GeodesicActiveContourLevelSetImageFilter).</div><div><br></div><div>Regards,</div><div><br></div><div>Dawood</div><div><br></div><div><br></div><br>--- On <b>Mon, 3/14/11, mohammed abdel samea <i><mohammed_abdel_samea@yahoo.com></i></b> wrote:<br><blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px;"><br>From: mohammed abdel samea <mohammed_abdel_samea@yahoo.com><br>Subject: Re: ThresholdLevelSetSegemntation Filter<br>To:
"Dawood Masslawi" <davoud_zzz@yahoo.com><br>Cc: insight-users@itk.org<br>Date: Monday, March 14, 2011, 9:13 PM<br><br><div id="yiv1632450515"><style type="text/css"><!--#yiv1632450515 DIV {margin:0px;}--></style><div style="font-family:times new roman, new york, times, serif;font-size:12pt;"><div style="font-family:times new roman, new york, times, serif;font-size:12pt;">Hi Dawood,<br><br>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!!.<br><br>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].<br><br>Thank you again for your help.<br><br>Best Regards,<br>Mohammed<br><div style="font-family:times new roman, new york, times, serif;font-size:12pt;"><font size="2" face="Tahoma"><hr size="1"><b><span
style="font-weight:bold;">From:</span></b> Dawood Masslawi <davoud_zzz@yahoo.com><br><b><span style="font-weight:bold;">To:</span></b>
mohammed_abdel_samea@yahoo.com<br><b><span style="font-weight:bold;">Cc:</span></b> insight-users@itk.org<br><b><span style="font-weight:bold;">Sent:</span></b> Sun, March 13, 2011 6:37:53 AM<br><b><span style="font-weight:bold;">Subject:</span></b> RE: ThresholdLevelSetSegemntation Filter<br></font><br>
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;font-size:inherit;line-height:inherit;font-size-adjust:inherit;font-stretch:inherit;" valign="top"><div id="yiv1632450515"><table id="yiv1632450515bodyDrftID" class="yiv1632450515" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td id="yiv1632450515drftMsgContent" style="font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-size-adjust:inherit;font-stretch:inherit;font-family:arial;font-size:10pt;">Hi Mohammed,<div><br></div><div>1. Try to change your internal pixel type from float to unsigned char or unsigned short </div><div><br></div><div>(or RGB if they are colored).</div><div><br></div><div>2. Correct, 99.9% :), fast marching segmentation is used to produce the initial level set.</div><div><br></div><div>The initial
distance approximates the distance between the seed points and the level set.</div><div><br></div><div>3. The threshold is assigned by the user and finding an optimum value depends on the</div><div><br></div><div>intensity values of the region to be
segmented.</div><div><br></div><div>HTH,</div><div><br></div><div>Dawood</div><div><br></div><div><br></div></td></tr></tbody></table>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<</div><div id="yiv1632450515"><br></div><div id="yiv1632450515">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<</div><div id="yiv1632450515"><br></div><div id="yiv1632450515"><br></div><div id="yiv1632450515"><span class="yiv1632450515Apple-style-span" style="font-family:times, serif;font-size:16px;line-height:19px;">Dear all,<br
style="line-height:1.2em;outline-style:none;"><br style="line-height:1.2em;outline-style:none;">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 style="line-height:1.2em;outline-style:none;">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 style="line-height:1.2em;outline-style:none;"><br style="line-height:1.2em;outline-style:none;"><br style="line-height:1.2em;outline-style:none;"><br style="line-height:1.2em;outline-style:none;">typedef float
InternalPixelType;<br style="line-height:1.2em;outline-style:none;">const unsigned int Dimension = 3;<br style="line-height:1.2em;outline-style:none;">typedef itk::Image< InternalPixelType, Dimension > InternalImageType;<br style="line-height:1.2em;outline-style:none;">typedef unsigned
char OutputPixelType;<br style="line-height:1.2em;outline-style:none;">typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br style="line-height:1.2em;outline-style:none;">typedef itk::BinaryThresholdImageFilter<InternalImageType, OutputImageType> ThresholdingFilterType;<br style="line-height:1.2em;outline-style:none;">ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New(); <br style="line-height:1.2em;outline-style:none;">thresholder->SetLowerThreshold( -1000.0 );<br style="line-height:1.2em;outline-style:none;">thresholder->SetUpperThreshold( 0.0 );<br style="line-height:1.2em;outline-style:none;">thresholder->SetOutsideValue( 0 );<br
style="line-height:1.2em;outline-style:none;">thresholder->SetInsideValue( 255 );<br style="line-height:1.2em;outline-style:none;">typedef itk::ImageFileReader< InternalImageType > ReaderType;<br style="line-height:1.2em;outline-style:none;">typedef itk::ImageFileWriter< OutputImageType > WriterType;<br style="line-height:1.2em;outline-style:none;">ReaderType::Pointer reader = ReaderType::New();<br style="line-height:1.2em;outline-style:none;">WriterType::Pointer writer = WriterType::New();<br style="line-height:1.2em;outline-style:none;">reader->SetFileName( file );<br style="line-height:1.2em;outline-style:none;">reader->Update();<br style="line-height:1.2em;outline-style:none;">writer->SetFileName( "aaa.tif" );<br style="line-height:1.2em;outline-style:none;">typedef itk::FastMarchingImageFilter< InternalImageType, InternalImageType >
FastMarchingFilterType;<br style="line-height:1.2em;outline-style:none;">FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();<br style="line-height:1.2em;outline-style:none;">const InternalImageType * inputImage = reader->GetOutput();<br style="line-height:1.2em;outline-style:none;">fastMarching->SetOutputRegion( inputImage->GetBufferedRegion() );<br style="line-height:1.2em;outline-style:none;">fastMarching->SetOutputSpacing( inputImage->GetSpacing() );<br style="line-height:1.2em;outline-style:none;">fastMarching->SetOutputOrigin( inputImage->GetOrigin() );<br style="line-height:1.2em;outline-style:none;">fastMarching->SetOutputDirection( inputImage->GetDirection() );<br style="line-height:1.2em;outline-style:none;">typedef
itk::ThresholdSegmentationLevelSetImageFilter< InternalImageType, InternalImageType > ThresholdSegmentationLevelSetImageFilterType;<br style="line-height:1.2em;outline-style:none;">ThresholdSegmentationLevelSetImageFilterType::Pointer thresholdSegmentation = ThresholdSegmentationLevelSetImageFilterType::New();<br style="line-height:1.2em;outline-style:none;">thresholdSegmentation->SetPropagationScaling( 1.0 );<br style="line-height:1.2em;outline-style:none;">thresholdSegmentation->SetCurvatureScaling( 1.0 );<br style="line-height:1.2em;outline-style:none;">thresholdSegmentation->SetMaximumRMSError( 0.02 );<br style="line-height:1.2em;outline-style:none;">thresholdSegmentation->SetNumberOfIterations( 1200 );<br style="line-height:1.2em;outline-style:none;">thresholdSegmentation->SetUpperThreshold( 250 );<br style="line-height:1.2em;outline-style:none;">thresholdSegmentation->SetLowerThreshold( 30 );<br
style="line-height:1.2em;outline-style:none;">thresholdSegmentation->SetIsoSurfaceValue(0.0);<br style="line-height:1.2em;outline-style:none;">typedef FastMarchingFilterType::NodeContainer NodeContainer;<br style="line-height:1.2em;outline-style:none;">typedef
FastMarchingFilterType::NodeType NodeType;<br style="line-height:1.2em;outline-style:none;">NodeContainer::Pointer seeds = NodeContainer::New();<br style="line-height:1.2em;outline-style:none;">InternalImageType::IndexType seedPosition;<br style="line-height:1.2em;outline-style:none;">seedPosition[0] = 358;<br style="line-height:1.2em;outline-style:none;">seedPosition[1] = 529;<br style="line-height:1.2em;outline-style:none;">seedPosition[2] = 2;<br style="line-height:1.2em;outline-style:none;">const double initialDistance = 5.0;<br style="line-height:1.2em;outline-style:none;">NodeType node;<br style="line-height:1.2em;outline-style:none;">const double seedValue = - initialDistance;<br style="line-height:1.2em;outline-style:none;">node.SetValue( seedValue );<br style="line-height:1.2em;outline-style:none;">node.SetIndex(
seedPosition );<br style="line-height:1.2em;outline-style:none;">seeds->Initialize();<br style="line-height:1.2em;outline-style:none;">seeds->InsertElement( 0, node );<br style="line-height:1.2em;outline-style:none;">fastMarching->SetTrialPoints( seeds );<br style="line-height:1.2em;outline-style:none;">fastMarching->SetSpeedConstant( 1.0 );<br style="line-height:1.2em;outline-style:none;">fastMarching->Update();<br style="line-height:1.2em;outline-style:none;">thresholdSegmentation->SetInput( fastMarching->GetOutput() );<br style="line-height:1.2em;outline-style:none;">thresholdSegmentation->SetFeatureImage( reader->GetOutput() );<br style="line-height:1.2em;outline-style:none;">thresholdSegmentation->Update();<br style="line-height:1.2em;outline-style:none;">thresholder->SetInput( thresholdSegmentation->GetOutput() );<br style="line-height:1.2em;outline-style:none;">thresholder->Update();<br
style="line-height:1.2em;outline-style:none;">writer->SetInput( thresholder->GetOutput() );<br style="line-height:1.2em;outline-style:none;">writer->Update();<br style="line-height:1.2em;outline-style:none;"><br style="line-height:1.2em;outline-style:none;"><br style="line-height:1.2em;outline-style:none;">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 style="line-height:1.2em;outline-style:none;"><br style="line-height:1.2em;outline-style:none;">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. <br style="line-height:1.2em;outline-style:none;"><br style="line-height:1.2em;outline-style:none;">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?.<br style="line-height:1.2em;outline-style:none;"><br style="line-height:1.2em;outline-style:none;">Best Regards,<br style="line-height:1.2em;outline-style:none;"> Mohammed</span></div></td></tr></tbody></table><br>
</div></div>
</div><br>
</div></blockquote></div></td></tr></tbody></table><br>
</div></blockquote></div></td></tr></table><br>