[vtkusers] Voxel Data from MATLAB to VTK

David Gobbi david.gobbi at gmail.com
Mon May 17 12:49:19 EDT 2010


The image data is stored in a vtkDataArray, so if you're specifically
looking to move images back and forth then you should definitely use
vtkDataArray and not vtkArray.  The vtkDataArray also has a
SetVoidPointer method.

For images there is are helper class called vtkImageImport and
vtkImageExport that will do the vtkDataArray->SetVoidPointer() trick
for you, they are what I use to move images back and forth between VTK
and Python.

In Python, I create an array of the desired dimensions, and then tell
VTK to use the array as a "buffer" i.e. to directly use the array as
storage space for the image.  The same should definitely be possible
for Matlab, but I've never tried it (I have tried it for Matlab with
ITK, and it works there FWIW).

   David


On Mon, May 17, 2010 at 10:26 AM, Brian Davis <bitminer at gmail.com> wrote:
> Ok Gmail snafu accidentally sent prematurely last email
>
> I also looked at the examples for ... (continuing on from previous email)
> examples of arrays
>
> http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Infovis/Testing/Cxx/ArrayMatricizeArray.cxx?root=VTK&content-type=text/plain
>
> and I did find the Matlab engine filter which appears to be a way to call
> Matlab engine form vtk, but I don't think I can use this for my purposes.
>
> http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Graphics/Testing/Cxx/TestMatlabEngineFilter.cxx?root=VTK&content-type=text/plain
>
> I started with the Arrays as an approach but then realized that there is no
> good way *that I can see* to get it to image data.  I liked the array
> approach for the block copy (or at least what I think is a block copy with
> no actual copying of the data occuring):
>
> vtkArray->SetVoidArray( (void *) volumeData, y_dim*x_dim*z_dim , 1);
>
> I was then hoping to resize/reshape data without loosing the data.. though
> api makes references to data loss.
>
> None of the other api objects seem to have the ability to set a pointer to
> the data and reshape as needed without copying the array or having to result
> to for loops.
>
> -Again sorry for 2 part email
>
> Brian.
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK 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