[vtkusers] Byte array from a Dicom Image
David Gobbi
david.gobbi at gmail.com
Fri Jan 24 18:24:48 EST 2014
Hi Matias,
If you have a vtkImageData object, you can get the array though
VTK's abstract data set interface. Here's an example:
vtkImageData *image = reader->GetOutput();
vtkDataArray *array = image->GetPointData()->GetScalars();
This will return an array that contains the scalars that are
associated with each point in the data. For vtkImageData, this
means the length of the array is the number of pixels in the image,
so the length will be 262144 (which is 512*512).
If the data is DICOM, the array will probably already be either a
vtkUnsignedShortArray or a vtkShortArray (signed short). But to
be sure, you can do a conversion:
vtkUnsignedShortArray *ushortArray = vtkUnsignedShortArray::New();
ushortArray->DeepCopy(array);
With the ushort array, you can use GetValue(i) to get one of the values.
David
On Fri, Jan 24, 2014 at 3:46 PM, Matias Montroull <matimontg at gmail.com> wrote:
> Hi,
>
> is there a way to obtain the byte array from a Dicom Image?
>
> I can display the image but I also need to extract the byte data, it's a
> 512X512 16 bits image, so I need the Ushort array.
>
> Thanks!
More information about the vtkusers
mailing list