[Insight-developers] Region bug in PNGImageIO
Miller, James V (Research)
millerjv@crd.ge.com
Tue, 1 Apr 2003 14:38:58 -0500
Okay. ImageIOBase::GetImageSizeInBytes() looks at the m_Dimensions
ivar. ImageFileWriter sets the dimensions of the ImageIO object
using the Size of the LargestPossibleRegion (this should probably be
the Size of RequestedRegion) which is the same Size that is set on the
IORegion. I assume somewhere in the Analyze writer you need to specify
how many row, cols, slices are in the image. So you are probably
getting that from m_Dimensions which was set as the Size of the
IORegion. So the IORegion is in some sense being used.
If you rely on GetImageSizeInBytes() to tell you how big the "buffer"
is write, then that "buffer" better match that size. This is one of
the disconnects in the system. The buffer, region, dimensions are
being consistly assigned. As it stands now, GetImageSizeInBytes()
and the IORegion are set using the LargestPossibleRegion but the
"buffer" is based on the BufferedRegion.
The situation gets more complicated when a writer cannot just
write the "buffer" as one block. It looks like the AnalyzeIO can
write the buffer as one block. But the PNG library requires
each "row" be passed down as a separate block. I assume this is
because the compression in PNG is done on a row by row basis.
So the PNG writer needs to know the address of the first pixel
in each row. Furthermore, it should probably be able to write
a volume a slice at a time. In any event, the PNG writer needs
to know how to index into the buffer to get to the block of
data that is pertinent for the file. To me this should be
the RequestedRegion (which in many circumstances will be the
same as the BufferedRegion and the LargestPossibleRegion).
My confusion/issue lies in the IORegion. The documentation says:
/** Specify the region of the image data to either read or
* write. The IORegion specifies the part of the image to read or
* write. Regions are defined with an index and a size vector. These
* vectors define the start (lower-left corner) and length of the
* region within the image. Make sure that the IORegion lies within
* the image. */
itkSetMacro(IORegion, ImageIORegion);
itkGetMacro(IORegion, ImageIORegion);
Since the IORegion specifies the part of the image to read or write, how is
the "entirety" of the image (LargestPossibleRegion) and "current amount"
(BufferedRegion) of the image specified to the ImageIO object.
> -----Original Message-----
> From: Kent Williams [mailto:kent@mail.psychiatry.uiowa.edu]
> Sent: Tuesday, April 01, 2003 12:48 PM
> To: Insight Developers List
> Subject: Re: [Insight-developers] Region bug in PNGImageIO
>
>
> Well, I can tell you what the code does; it's being passed a
> pointer to the
> buffer; it computes the number of bytes to write out by calling
> itk::ImageIOBase->GetImageSizeInBytes() to determine
> dimensions and the size
> of pixel data. So it is taking the image size into account.
>
> Now, itk::ImageIOBase->GetImageSizeInBytes() doesn't take
> m_IORegion into
> account; in fact itkImageSeriesWriter.txx is the only file
> that seems to do
> anything with it, and I've only done a cursory glance through
> the code, so
> I'm not sure what it is, in fact, doing.
>
>
> On Tuesday 01 April 2003 11:34 am, Miller, James V (Research) wrote:
> > So how do you determine what the image dimensions to write are
> > if you are not looking at the m_IORegion?
> >
> > Are you just supporting "overwriting" and existing image and getting
> > the dimensions from the previously stored image?
> >
> > Jim
> >
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers
>