[Insight-users] OTSU test code

Uday Kurkure Uday Kurkure" <udaykurkure@rediffmail.com
20 Sep 2002 21:46:57 -0000


Hi Louis,

I am wondering how I forgot about Update() function. Thanks for 
explaining me the pipeline. Will keep that in mind.
I added the Update() function and removed the writer part and 
BINGO! it is working perfectly. But I get run-time error if I 
don't explicitly specify the IO object/factory. It's fine with me 
to explicitly specify them but since you mentioned that now we 
don't need to specify them, I am curious how to make it work. Can 
you throw some light on it?

Thanks,
Uday Kurkure.



>Also, note that for PNG, VTK, Meta and Dicom you no
>longer need to explicity specify the IO object nor
>the IO factory. Default factories for these formats
>are now registered at construction time in the IO
>framework.
>
>The following code should be enough:
>
>
>
>   reader->SetFileName("input.png");
>   reader->Update();
>   calculator->SetInput( reader->GetOutput() );
>   calculator->Compute();
>   PixelType threshold = calculator->GetThreshold();
>
>
>
>
>Please let us know if you find further problems
>
>   Thanks
>
>
>    Luis
>
>
>==========================================
>
>
>Uday Kurkure wrote:
>
>>
>>
>>Hello all,
>>
>>Thanks Louis and Sayan for your suggestions.
>>
>>I could successfully run the OTSU test code. Now I have modified 
>>it to take a PNG image as input. It is working fine for this 
>>part of code:
>>
>>//----------------------------------------------------------------
>>   // Read in the image
>>   itk::PNGImageIO::Pointer io;
>>   io = itk::PNGImageIO::New();
>>   typedef unsigned char PixelType;
>>   typedef itk::Image<PixelType, 2> myImage;
>>   itk::ImageFileReader<myImage>::Pointer input
>>     = itk::ImageFileReader<myImage>::New();
>>   input->SetFileName(av[0]);
>>   input->SetImageIO(io);// comment it if using factory
>>
>>   // write the input image
>>   itk::ImageFileWriter<myImage>::Pointer writer1;
>>   writer1 = itk::ImageFileWriter<myImage>::New();
>>   writer1->SetInput(input->GetOutput());
>>   writer1->SetFileName("myinput.png");
>>   writer1->SetImageIO(io);// comment it if using factory
>>   writer1->Write();
>>   // Create and initialize the calculator
>>   CalculatorType::Pointer calculator = CalculatorType::New();
>>   calculator->SetImage(input->GetOutput());
>>   calculator->SetNumberOfHistogramBins( 256);
>>   calculator->Compute();
>>//--------------------------------------------------------------
>>
>>But if I don't write out the image (comment the writer1 code 
>>lines)
>>it always give threshold 0. I want to remove the writing part. 
>>Can some one suggest something.
>>
>>Thanks,
>>Uday Kurkure.
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users@public.kitware.com
>>http://public.kitware.com/mailman/listinfo/insight-users
>>
>
>
>