[Insight-users] Problem writing small images
Chris Farmer
cfarmer at scitegic.com
Wed Jan 18 11:30:19 EST 2006
Hi Luis,
Thanks for the explanation. I understand that it's weird to want to
compress (or even view) a 1-pixel image. I was trying to put together
what basically amounts to a debugging tool for my app that shows binary
image features that have been found after segmenting a larger image. I
was showing these in a web browser, which is why I wanted to use png or
jpg. If the user has entered reasonable parameters, then this isn't
usually an issue, but it's not too hard for users to get the occasional
1-pixel image. I suppose I will just not show the image in my result
when this condition applies.
Thanks,
Chris
-----Original Message-----
From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
Sent: Wednesday, January 18, 2006 5:17 AM
To: Chris Farmer
Cc: insight-users at itk.org
Subject: Re: [Insight-users] Problem writing small images
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
--
Click on the link below to report this email as spam
https://www.mailcontrol.com/sr/fGwlLPEoUVCKHWvUZ8Ray1hYR2Ea7MQOzyW2!+LeX
n1zFtfOWtrU40NgogRSwr8mQx1onJWYSQJJS+XJclkxA+OpOycN7xkj9yt9!MZakhcA15E7D
z+QraIIfevi!SH9NUb9u0Hu7eObIW4VOX16Zvmv4CNDFX7sRxwl9fGM9VYXwd85LTFUYg3Ke
F2R+Fd9pqVVQlJIWZf+rjou24cmeSL1LEjkJQbW
More information about the Insight-users
mailing list