[vtkusers] how to convert 3d volume array (short [ , , ]) to vtkvolume

Christian Lackas lackas at invicro.com
Mon Mar 14 04:25:39 EDT 2011


* Sarah Saeed <sosca7 at hotmail.com> [110313 12:40]:

Hi Sarah,

> can anyone help me ? i have a 3D array of shortint[ Z,Y,X] can i
> convert it to vtkvolume or any format to extract a volume from it.

you can use vtkImageImport[1] to import data from a C array.
E.g. in C++:

    short *data = ...

    importerROI->SetImportVoidPointer( data );
    importerROI->SetDataScalarTypeToShort();    // default
    importerROI->SetWholeExtent( 0, Z-1, 0, Y-1, 0, X-1 );
    importerROI->SetDataExtentToWholeExtent();

To set the orientation of your image properly, see the class
documentation.

[1] http://www.vtk.org/doc/nightly/html/classvtkImageImport.html

Christian

-- 
http://www.invicro.com/



More information about the vtkusers mailing list