[vtkusers] How get Binary data of vtkimagedata.

David Gobbi dgobbi at atamai.com
Mon Mar 26 09:38:17 EDT 2007


Hi Francois,

The vtkImageWriter will write an image as a raw binary file. Depending 
on what software you will use to read the .bin image, you might have to 
use vtkImageShiftScale to convert the data to the correct scalar type 
(unsigned char, short, unsigned short) before you write the data with 
vtkImageWriter.

To access the data directly without writing it to disk, you can use this:

// "image" is a vtkImageData
image->Update();
vtkDataArray *array = image->GetPointData()->GetScalars();

This will give you the vtkDataArray that contains all of the voxel values.

In vtkImageData, the pixel values are associated with the "points" in 
the data set. The "CellData" is never used in a vtkImageData.

- David


Francois Louis LAILLIER wrote:
>
> Hello everybody.
>
> I have a vtkimagedata,with data of a slice.
>
> I want extract binary data, to put it in .bin files to read with other 
> procedure.
>
> Maybe I can extract celldata, but I don’t find document for the 
> function Copydata…..
>
> If you have other solution, can you help me please?
>
> Thanks in advance,
>
> Best regards, Francois Louis
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>   




More information about the vtkusers mailing list