<DIV>
<DIV>Hello All,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I am new to ITK and currently trying to check with Level set segmentation methods. </DIV>
<DIV>I have written following code to refine the segmentation of Threshold Level Set.&nbsp; I have used different types of images for this as input.&nbsp; The problem is:&nbsp; speed image returned is of 0 bytes, basically GetRegionIO() receives 0 as dimension of the input image. </DIV>
<DIV>Does anyone have idea why this is happening? </DIV>
<DIV>&nbsp;</DIV>
<DIV>Ex. --&gt; </DIV>
<DIV>Input Files used --&gt;<BR>Input FileName&nbsp;&nbsp; --&gt; c:\\BrainT1Slice_thresholdLevelSet.png<BR>Feature Image&nbsp;&nbsp;&nbsp; --&gt; c:\\BrainT1Slice.png<BR>Output FileName&nbsp; --&gt; c:\\BrainT1Slice_output.png</DIV>
<DIV>&nbsp;</DIV>
<DIV>Command Line paramters are used as --&gt; <BR>c:\\BrainT1Slice.png&nbsp; 0.02 20&nbsp; c:\\BrainT1Slice_thresholdLevelSet.png 10 128 10 -1 1 -1 -1 -1 -1 -1 -1 0.3 30&nbsp; c:\\BrainT1Slice_op.png</DIV>
<DIV>&nbsp;</DIV>
<DIV>int main( int argc, char *argv[] )<BR>{</DIV>
<DIV>&nbsp;FILE *fp = fopen("c:\\check.txt", "w+");<BR>&nbsp;if(NULL != fp ){<BR>&nbsp;&nbsp;fprintf(fp,"argv[1] Input File Name --&gt; %s \n", argv[1]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[2] RMS Error --&gt; %s \n", argv[2]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[3] Maximum Number Of Iterations--&gt; %s \n", argv[3]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[4] Input File #2 --&gt; %s \n", argv[4]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[5] Variance --&gt; %s \n", argv[5]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[6] Iso-Surface Value --&gt; %s \n", argv[6]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[7] Lower Threshold --&gt; %s \n", argv[7]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[8] Upper Threshold --&gt; %s \n", argv[8]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[9] AdvectionScaling--&gt; %s \n", argv[9]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[10] SeedX --&gt; %s \n", argv[10]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[11] SeedY --&gt; %s \n", argv[11]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[12] X-Radius/InitialDistance--&gt; %s \n",
 argv[12]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[13] Y-Radius --&gt; %s \n", argv[13]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[14] SeedX2 --&gt; %s \n", argv[14]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[15] SeedY2 --&gt; %s \n", argv[15]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[16] Propagation Scaling --&gt; %s \n", argv[16]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[17] Curvature Scaling --&gt; %s \n", argv[17]);<BR>&nbsp;&nbsp;fprintf(fp,"argv[18] Output File Name --&gt; %s \n", argv[18]);&nbsp;&nbsp;<BR>&nbsp;}<BR>&nbsp;fclose(fp);&nbsp;</DIV>
<DIV>&nbsp; typedef&nbsp;&nbsp; float&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InternalPixelType;&nbsp; <BR>&nbsp; const&nbsp;&nbsp;&nbsp;&nbsp; unsigned int&nbsp;&nbsp;&nbsp; Dimension = 2;<BR>&nbsp; typedef&nbsp;unsigned char&nbsp;OutputPixelType;</DIV>
<DIV>&nbsp; typedef&nbsp;itk::Image&lt; InternalPixelType, Dimension &gt;&nbsp; InternalImageType;<BR>&nbsp; typedef&nbsp;itk::Image&lt; OutputPixelType, Dimension &gt; OutputImageType;</DIV>
<DIV>&nbsp; typedef&nbsp;itk::BinaryThresholdImageFilter&lt; InternalImageType, OutputImageType &gt; ThresholdingFilterType;<BR>&nbsp; typedef&nbsp;itk::ImageFileReader&lt; InternalImageType &gt; ReaderType;<BR>&nbsp; typedef&nbsp;itk::ImageFileWriter&lt;&nbsp; OutputImageType&nbsp; &gt; WriterType;&nbsp; </DIV>
<DIV>&nbsp; typedef&nbsp;&nbsp; float&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InternalPixelType;<BR>&nbsp; typedef unsigned char OutputPixelType;<BR>&nbsp; typedef itk::BinaryThresholdImageFilter&lt;InternalImageType, OutputImageType&gt; ThresholdingFilterType;<BR>&nbsp; ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp; float&nbsp;&nbsp;propgationScale = 0.0, curvatureScale = 0.0;</DIV>
<DIV>&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 reader1 = ReaderType::New();<BR>&nbsp; ReaderType::Pointer reader2 = ReaderType::New();<BR>&nbsp; WriterType::Pointer writer = WriterType::New();</DIV>
<DIV>&nbsp; reader1-&gt;SetFileName( argv[1] ); // Feature image (smoothed image)<BR>&nbsp; reader2-&gt;SetFileName( argv[4] ); // already segmented initial model <BR>&nbsp; writer-&gt;SetFileName(&nbsp; argv[18] ); // output file name&nbsp;&nbsp; </DIV>
<DIV>&nbsp; thresholder-&gt;SetUpperThreshold( 10.0 );<BR>&nbsp; thresholder-&gt;SetLowerThreshold( 0.0 );<BR>&nbsp; thresholder-&gt;SetOutsideValue(&nbsp; 0&nbsp; );<BR>&nbsp; thresholder-&gt;SetInsideValue(&nbsp; 255 );&nbsp; <BR>&nbsp; <BR>&nbsp; typedef&nbsp; itk::CannySegmentationLevelSetImageFilter&lt; InternalImageType, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InternalImageType &gt; CannySegmentationLevelSetImageFilterType;<BR>&nbsp; CannySegmentationLevelSetImageFilterType::Pointer cannySegmentation = <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CannySegmentationLevelSetImageFilterType::New();&nbsp; <BR>&nbsp; <BR>&nbsp; cannySegmentation-&gt;SetAdvectionScaling( ::atof(argv[9]) );<BR>&nbsp; cannySegmentation-&gt;SetCurvatureScaling( ::atof(argv[17]) );<BR>&nbsp; cannySegmentation-&gt;SetPropagationScaling( 0.0 );</DIV>
<DIV>&nbsp; // For cases in which some surface expansion is to be allowed, a non-zero value may be set for the<BR>&nbsp; // propagation term. The propagation term is simply D.&nbsp; Here,we set it to 0.0&nbsp;&nbsp;&nbsp; <BR>&nbsp; // The maximum number of iterations is specified from the command line. It may not be desirable in some <BR>&nbsp; // applications to run the filter to convergence.&nbsp; Only a few iterations may be required.<BR>&nbsp; <BR>&nbsp; cannySegmentation-&gt;SetMaximumRMSError( ::atof(argv[2]) );<BR>&nbsp; cannySegmentation-&gt;SetNumberOfIterations( ::atoi(argv[3]) );&nbsp; <BR>&nbsp; cannySegmentation-&gt;SetThreshold( ::atof(argv[7]) );<BR>&nbsp; cannySegmentation-&gt;SetVariance(&nbsp; ::atof(argv[5]) );&nbsp; <BR>&nbsp; cannySegmentation-&gt;SetIsoSurfaceValue( ::atof(argv[6]) );&nbsp; <BR>&nbsp; cannySegmentation-&gt;SetInput( reader2-&gt;GetOutput() );<BR>&nbsp; cannySegmentation-&gt;SetFeatureImage( reader1-&gt;GetOutput() );<BR>&nbsp;
 thresholder-&gt;SetInput( cannySegmentation-&gt;GetOutput() );&nbsp; </DIV>
<DIV>&nbsp; writer-&gt;SetInput( thresholder-&gt;GetOutput() );</DIV>
<DIV>&nbsp; // Examining the propagation (speed) and advection images can help the process of tuning parameters.&nbsp; <BR>&nbsp; // These images are available using \code{Set/Get} methods from the filter after it has been updated.<BR>&nbsp; <BR>&nbsp; try {<BR>&nbsp;&nbsp;&nbsp; writer-&gt;Update();<BR>&nbsp; }<BR>&nbsp; catch( itk::ExceptionObject &amp; excep ) {<BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Exception caught !" &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; excep &lt;&lt; std::endl;<BR>&nbsp; }</DIV>
<DIV>&nbsp; // Print useful information<BR>&nbsp; std::cout &lt;&lt; std::endl;<BR>&nbsp; std::cout &lt;&lt; "Max. no. iterations: " &lt;&lt; cannySegmentation-&gt;GetNumberOfIterations() &lt;&lt; std::endl;<BR>&nbsp; std::cout &lt;&lt; "Max. RMS error: " &lt;&lt; cannySegmentation-&gt;GetMaximumRMSError() &lt;&lt; std::endl;<BR>&nbsp; std::cout &lt;&lt; std::endl;<BR>&nbsp; std::cout &lt;&lt; "No. elpased iterations: " &lt;&lt; cannySegmentation-&gt;GetElapsedIterations() &lt;&lt; std::endl;<BR>&nbsp; std::cout &lt;&lt; "RMS change: " &lt;&lt; cannySegmentation-&gt;GetRMSChange() &lt;&lt; std::endl;&nbsp;&nbsp; </DIV>
<DIV>&nbsp; // Write out the speed (propagation) image for parameter tuning purposes.<BR>&nbsp; //itk::ImageFileWriter&lt; OutputImageType &gt;::Pointer speedWriter = itk::ImageFileWriter&lt;OutputImageType&gt;::New();&nbsp; <BR>&nbsp; itk::ImageFileWriter&lt; InternalImageType &gt;::Pointer speedWriter = itk::ImageFileWriter&lt;InternalImageType&gt;::New();&nbsp; <BR>&nbsp; <BR>&nbsp; speedWriter-&gt;SetFileName( "Canny_speedImage.mhd" );&nbsp; <BR>&nbsp; speedWriter-&gt;SetInput( cannySegmentation-&gt;GetSpeedImage()); <BR>&nbsp; <BR>&nbsp; // Since output of LaplacianLevelSet is Float type, we need to rescale it to "unsigned char" (for png).<BR>&nbsp; /*typedef itk::RescaleIntensityImageFilter&lt; InternalImageType, OutputImageType &gt; RescaleFilterType;&nbsp;<BR>&nbsp; RescaleFilterType::Pointer rescaler = RescaleFilterType::New();&nbsp;&nbsp;&nbsp; <BR>&nbsp; <BR>&nbsp; // Set Rescaler Parameters<BR>&nbsp; rescaler-&gt;SetOutputMinimum( 0 ); <BR>&nbsp;
 rescaler-&gt;SetOutputMaximum( 255 );&nbsp; <BR>&nbsp; <BR>&nbsp; speedWriter-&gt;SetFileName( "Canny_speedImage.mhd" );&nbsp; <BR>&nbsp; rescaler-&gt;SetInput( cannySegmentation-&gt;GetSpeedImage());&nbsp;&nbsp; <BR>&nbsp; speedWriter-&gt;SetInput( rescaler-&gt;GetOutput() );&nbsp; */</DIV>
<DIV>&nbsp;&nbsp; <BR>&nbsp; try { speedWriter-&gt;Update(); }</DIV>
<DIV>&nbsp; catch( itk::ExceptionObject &amp; excep ){<BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Exception caught !" &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; excep &lt;&lt; std::endl;<BR>&nbsp; }&nbsp;&nbsp; </DIV>
<DIV>&nbsp; return 0;<BR>} // end of&nbsp; main<BR></DIV></DIV><p>
                <hr size=1>Do you Yahoo!?<br> 
Yahoo! Small Business - <a href="http://us.rd.yahoo.com/evt=31637/*http://smallbusiness.yahoo.com/resources/">Try our new resources site!</a>