[Insight-users] Multiresolution turns my images into black images:
PNG 16 bits
Luis Ibanez
luis . ibanez at kitware . com
Sun, 23 Nov 2003 20:30:03 -0500
Hi Adolfo,
Your problem is totally unrelated to the
multiresolution pyramid.
What happens is that you are saving images as
PNG files with 16bits but those images have
a dynamic range of only 8 bits. Since most
viewers do not normalize the images, the image
*looks* black on the screen even though the
information is in there.
You have several options
1) convert the output images to 8 bits
before saving it, making sure that you
declare the ImageFileWriter to be of
type Image<unsigned char,2>
2) fill the 16bits dynamic range by using
the RescaleIntensityImageFilter
3) Don't use PNG for saving the images but
a format like MetaImage
4) For viewing images use the ImageViewer
application available in
InsightApplications/ImageViewer
Regards,
Luis
----------------------------
Adolfo González Uzábal wrote:
> Hello everybody there!
>
> I'm just starting working with the MultiresolutionPyramidFilter in ITK 1.4
>
> I read a .png image, put it into a multiresolution pyramid,
> update it and try to get written the output images.
>
> But the images are totally black.
>
> I've tried the following:
> .- Recover the input of the pyramid and get it written.
> OK. I got the image as I had put it.
> .- Change the Schedule for resolutions.
> OK. The output sizes changes accordingly to the new schedule.
> .- In the forum I've seen some advice from Ms.Ng, about pixel types. I've tried
> with uchar, uint and float with no good results.
>
> I suppose I've missed any step in the generation process.
>
> You can find the main part of my source attached (I've leave out some try/catch
> structs just to be clearer).
>
> Any suggestion or advice will be truly appreciated.
>
> Best wishes!
> Adolfo G.U.
>
> -------------------------------------
> typedef unsigned char PixelType;
> const unsigned int Dimension = 2;
> const unsigned int numberOfLevels = 2;
> typedef itk::Image< PixelType, Dimension > ImageType;
>
> typedef itk::ImageFileReader< ImageType > ReaderType;
> typedef itk::ImageFileWriter< ImageType > WriterType;
> typedef itk::PNGImageIO ImageIOPNGType;
>
> ReaderType::Pointer reader = ReaderType::New();
> WriterType::Pointer writer = WriterType::New();
> ImageIOPNGType::Pointer pngIO = ImageIOPNGType::New();
>
> const char * inputFilename = "./Files/Circle.png";
> const char * outputFilename = "./Files/outputOriginal.png";
>
> reader->SetImageIO(pngIO);
> reader->SetFileName( inputFilename );
>
> typedef itk::MultiResolutionPyramidImageFilter<
> ImageType,
> ImageType > FixedImagePyramidType;
>
> FixedImagePyramidType::Pointer myPyramid =
> FixedImagePyramidType::New();
>
> myPyramid->SetNumberOfLevels(numberOfLevels );
> myPyramid->SetInput(reader->GetOutput() );
> myPyramid->Update();
>
> writer->SetInput( myPyramid->GetInput(0) );
> writer->SetFileName( "./Files/inputExtracted.png" );
> writer->Update(); // here everything goes properly
>
> for (int i = 0; i < myPyramid->GetNumberOfOutputs(); i++)
> {
> char tempFilename[50];
> sprintf( tempFilename, "./Files/outputResolution%d.png", i );
>
> writer->SetInput( myPyramid->GetOutput(i) );
> writer->SetFileName( tempFilename);
> writer->Update(); // ...but there I got only black images
> }
>
>