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