[Insight-users] Bug in itkPNGImageIO

Koen Van Leemput koen . vanleemput at hus . fi
Wed, 17 Jul 2002 15:50:28 +0300


Many thanks for your quick response, Luis. In the meanwhile, however, I c=
ame=20
across another bug in itkPNGImageIO, this time related to writing 3-D col=
or=20
images.

When writing a 3-D image with pixeltype RGBPixel<unsigned char>, the firs=
t PNG=20
file written is OK. The second and the third PNG files, however, contain =
a=20
mixture between the first and the second slice of the 3-D image. The four=
th=20
PNG file contains the second slice of the image, etc.

While I have not looked into it further, my guess is that the "offset"=20
argument in PNGImageIO::WriteSlice is again responsible...

Koen



On Monday 15 July 2002 15:44, Luis Ibanez wrote:
> Hi Koen,
>
> Thanks a lot for your bug report.
> Following your description the bug was fixed.
> You can cvs-update in order to get the corrected version.
>
> Also the "%s%d.png" format was changed for "%s%03d.png"
> in order to generate numbers like:
>
>            001,002,003,..,010,..,100
>
> instead of
>
>            1,2,3....,10,....,100
>
> In this way, when filenames are ordered lexicografically
> the order is consistent with the position of slices in
> the image.
>
>
> An Example was added to:
>
>        Insight/Examples/RawImageReadWrite
>
> it is called :
>
>        itkRawImageReadWritePNG.cxx
>
> It reads a Raw image and dump all the slices into PNG files.
>
> This can be used as an utility in itself.
>
>
> Thanks again,
>
>
>    Luis
>
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
>
> Koen Van Leemput wrote:
> > When writing a 3-D image with itkPNGImageIO, all the files "%s%d.png"
> > contain the same first slice of the data set. This appears to be caus=
es
> > by
> >
> > PNGImageIO::WriteSlice(std::string& fileName, const void* buffer,
> >                             unsigned long offset)
> >
> > in which the "offset" argument is not correctly handled.
> >
> > To replicate this error, use something like
> >
> > typedef  itk::ImageFileWriter< ImageType >      FileSinkType;
> > typedef  itk::PNGImageIO                              PNGWriterType;
> >
> > FileSinkType::Pointer      fileSink   =3D FileSinkType::New();
> > PNGWriterType::Pointer   PNGWriter  =3D PNGWriterType::New();
> >
> > fileSink->SetImageIO( PNGWriter );
> > fileSink->SetFilePrefix( outputFilePrefix );
> > fileSink->SetInput( fileSource->GetOutput() );
> > fileSink->Write();
> >
> > This should be easy to fix...
> >
> > Koen

--=20
*************************************************************************=
****=20
Koen Van Leemput, Ph.D.                email : koen.vanleemput@hus.fi=20
Department of Radiology                  phone: +358 9 471 71331       =20
Helsinki University Central Hospital   mobile: +358 9 471 62300       =20
P.O. Box 340                                  fax:      +358 9 471 71342 =
      =20
FIN-00029 HUS                                                            =
              =20
FINLAND                                                                  =
                 =20
*************************************************************************=
****=20