[Insight-users] MetaIO - problems reading a stack of PNG images
Stephen R. Aylward
aylward@unc.edu
Thu, 13 Mar 2003 17:59:17 -0500
Hi Gary,
You are specifying 1024x1024 unsigned short (2 byte) slices. Therefore
each file should be 2097152 bytes long.
1) ant.png.0 appears to only contain 833914 bytes - it is not a full
slice, or it is in png format - which is not a raw format, and therefore
cannot be read with metaImage.
2) ant.png.1, ant.png.2, etc appear to be empty
The MetaImage "format", as you appear to know, is basically just a text
file that contains image info that is commonly associated with medical
images (e.g., element spacing) and that names the file(s) of raw data
that is the medical image to be read. Regretfully MetaImage doesn't
currently support png images - only raw images.
The good news is that itk does support png data. So you have two options:
1) Read your data in as a series of 2D slices using itk's png reader and
then composite them into a 3D volume.
2) Or convert your png slices to raw slices and then use your metaImage
file. I recommend the convert program that comes with imageMagick:
www.imagemagick.org
Stephen
Gary O Tedeschi wrote:
> Hi,
>
> I am attempting to generate a 3D image from a stack of images, each slice
> in its own file. My MetaHeader is as follows:
>
> NDims = 3
> DimSize = 1024 1024 16
> ElementType = MET_USHORT
> HeaderSize = -1
> ElementSize = 0.081 0.081 0.651
> ElementByteOrderMSB = False
> ElementDataFile = ant.png.%d 0 15 1
>
> Upon execution I get the following error messages:
>
> Using string 'ant.png.%d' with values 0 to 15 stepping 1
> file = _ant.png.0_
> MetaImage: M_ReadElements: data not read completely
> ideal = 2097152 : actual = 833914
> file = _ant.png.1_
> MetaImage: M_ReadElements: data not read completely
> ideal = 2097152 : actual = 0
> file = _ant.png.2_
> MetaImage: M_ReadElements: data not read completely
> ideal = 2097152 : actual = 0
> file = _ant.png.3_
> MetaImage: M_ReadElements: data not read completely
> ideal = 2097152 : actual = 0
> file = _ant.png.4_
>
> ...etc.
>
> Any ideas on what I may be doing wrong?
>
> thank you,
> Gary
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
--
===============================================
Dr. Stephen R. Aylward
Assistant Professor of Radiology
Adjunct Assistant Professor of Computer Science
http://caddlab.rad.unc.edu
aylward@unc.edu
(919) 966-9695