[Insight-users] OTSU test code
Uday Kurkure
Uday Kurkure" <udaykurkure@rediffmail.com
20 Sep 2002 20:05:21 -0000
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.