[vtkusers] Re: How to read raw 8bpp volumes?

Dave Reed dreed at capital.edu
Thu Apr 18 14:45:28 EDT 2002


> From: Rene Tschirley <pooh at cs.tu-berlin.de>
> 
> Dear all,
> 
> 
> I hope my question isn't as stupid as I feel right now asking it:
> 
> For all the time I used vtkVolume16Reader to read 16bpp volume data and
> was very happy with it. Now, I have some MRI series which are 8bpp. I
> wonder how I have to read them. vtkVolume16Reader writes:
> "vtkVolume16Reader (0x8058b18): Error reaading raw pgm data!" (I wonder
> why it assumes PGM format, for the files are raw image data.) Do I have
> to convert my 8bpp slices to real PGM data or 16bpp files?
> 
> Thanks in advance,
>        René


I think the vtkImageReader is what you want (and from what I gather
from the documentation, this is the preferred way to read 16 bit data
also).

Here's a python code snippet to read 64 256x256 files named slice.1,
slice.2, ..., slice.64

   reader = vtkImageReader()
   reader.SetDataOrigin(0, 0, 0)
   reader.SetDataExtent(0, 255, 0, 255, 1, 64)
   reader.SetFilePrefix('slice')
   reader.SetDataScalarTypeToUnsignedChar() # for 8 bit data

HTH,
Dave



More information about the vtkusers mailing list