[Insight-users] Problem writing small images
Luis Ibanez
luis.ibanez at kitware.com
Wed Jan 18 08:16:42 EST 2006
Hi Chis,
What happens is that the PNGImageIO checks the image region that
it is about to write, and when it finds that the size of the image
along a particular direction is just 1 pixel, it assumes that this
is a degenerate image and considers it to be of dimension N-1.
It is arguable whether this is a correct behavior or not...
From the pragmatic point of view, I would suggest you to simply not
use PNG. For such small images, you may find more useful to use the
MetaImage file format.
For small images, you don't need the PNG compression, so there is
not much that PNG is doing for you at this point, except for making
hard for you to save the small images.
Please let us know if you have further questions,
Thanks
Luis
-------------------
Chris Farmer wrote:
>
>
> Hi all,
>
>
>
> I have a collection of potentially many images that I’m trying to write
> out as files. Most of these images are small, and some are only 1 pixel
> in size. I seem to have a problem with any images that are 1x1, 1x2, or
> 2x1 in size. Images that are 2x2 in size or bigger don’t seem to have a
> problem. I get an error like this:
>
>
>
> itk::ERROR: PNGImageIO(064DD690): PNG Writer can only write
> 2-dimensional images. You are requesting to write an image of dimension
> = 0 with filename C:\images\1x2output.png
>
>
>
> My code is straightforward....
>
>
>
> itk::ImageFileReader<Grayscale8ImageType>::Pointer r =
> itk::ImageFileReader<Grayscale8ImageType>::New();
>
> itk::ImageFileWriter<Grayscale8ImageType>::Pointer w =
> itk::ImageFileWriter<Grayscale8ImageType>::New();
>
> r->SetFileName("C:\\images\\1x2black.tif");
>
> w->SetFileName("C:\\images\\1x2output.png");
>
> w->SetInput(r->GetOutput());
>
> w->Update();
>
>
>
> A similar error occurs for other output types that I tried. Is there
> anything I can do to write out a small file like this? Yeah, I know
> there’s not much to be gained by looking at a 1-by-1 image, but…
>
>
>
> I’m currently using ITK 2.2 on Windows, but am not opposed to updating
> to a newer version. My test images are linked below. I don’t have my
> own publicly accessible web server, and all my tif files seem to get
> converted to png at the free image hosting sites, but png source files
> seem to give the same error.
>
>
>
> http://xs64.xs.to/pics/06033/1x1black.png
>
> http://xs64.xs.to/pics/06033/1x2black.png
>
>
>
>
>
>
>
> thanks,
>
> Chris
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list