[Insight-users] 2D slice from 3D image?

Luis Ibanez luis . ibanez at kitware . com
Fri, 10 Oct 2003 09:12:03 -0400


Hi Jianguo,

The example ImageReadExtractWrite in

       Insight/Examples/IO

is defining the image with pixel types

line 78:
>
>   typedef signed short        InputPixelType;
>   typedef signed short        OutputPixelType;
> 
>   typedef itk::Image< InputPixelType,  3 >    InputImageType;
>   typedef itk::Image< OutputPixelType, 2 >    OutputImageType;


Did you changed the OutputPixelType before running
this program  ?

The PNG image file format only manages "unsigned char"
and "unsigned short" pixel types. If you change the output
pixel type to anything different from those types, then
you will have to select a file format different from PNG
for storing your image. Possible options are:

         MetaImage, Analyze, Gipl, VTK....

If you really want to use PNG, then you could do casting
before writing the image to a file, as illustrated in the
example ImageReadCastWrite.cxx in the same directory.

Both examples are described in the SoftwareGuide

    http://www . itk . org/ItkSoftwareGuide . pdf

Section 7.3, pdf-page 224, paper page 198.




Regards,


   Luis


------------------
Rao Jianguo wrote:
> Hello everyone,
> 
> I am going to extract a 2D slice from 3D image.
> As there is already a command to do this, I simply
> run it:
> 
> ./ImageReadExtractWrite myImage.mha test.png 0
> 
> I got error message:
> 
> =========
> ../Insight/Code/Io/itkPNGImageIO.cxx line: 502
> Description:  itk::ERROR: PNGImageIO(0x808a570):
> PNG supports unsigned char and unsigned short
> 
> =========
> 
> I will be very grateful if someone can help.
> 
> Cheers,
> 
> Jianguo
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users
>