[vtkusers] Voxel Data from MATLAB to VTK

Brian Davis bitminer at gmail.com
Fri May 14 19:52:03 EDT 2010


I am using vtk-5.4.2 and I am wondering the best approach to moving an 3D
array of voxel data from MATLAB mex interface into the vtk pipeline.  I am
have been confused based on what is available to me, what is new, and what
is being deprecated.  I am also wondering if implementing and a class based
on vtkArray (abstract) would be an approach in order not to have to copy
data in memory, though I have and a feeling that it must be put into the vtk
vector structure at some point.  I currently have a working Matlab 2010a to
mex interface working and can call vtk


I have read:

http://www.itk.org/Wiki/VTK/VTKMatlab

which was updated circa 2006 and I am wondering if this is still the
appraoch based on the seemingly new vtkDenseArray.  Is there a better
approach to show voxel data in vtk from a 3D array in matlab?

and I have read

http://kitware.com/InfovisWiki/index.php/N-Way_Array_Data_Structures

and I had an opinion (yea doesn't everyone) on the following statements

--snip--
The vtkArray::Resize() method is used to set the number of dimensions and
extents along each dimension of an array. Overloads are provided for 1, 2,
or 3 dimensions, plus an overload that takes an instance of vtkArrayExtents
for working in higher dimensions.

    The "Resize" method can be efficiently implemented if it does not
preserve any data. Therefore it should be called SetSize and documented to
not initialize data unless an initial value is given. The vxl folks went
through this same decision process and created lots of incompatibilities by
changing the name...so it is better to have it right early. -Brad King

        From the documentation, Resize() explicitly does not preserve data,
and leaves the array contents in an undefined state. In fact, we don't
provide any mechanism to initialize the array contents in vtkArray, because
there aren't any initialization semantics that make sense for both dense and
sparse arrays - so we leave initialization to concrete subclasses. So the
only question is whether "Resize()" is the right name or not ... FWIW,
"SetSize()" doesn't seem better-or-worse to me. Tshead 16:27, 14 September
2009 (UTC)

--end snip--

I too read that Resize does not perserve data and felt sad.  I would perfer
the term used by Matlab called "Reshape" where your data stays put, but the
only thing that is changed structure of the pointers to the data.

I am currently doing the following in hopes to use the new template goop.
Anyone there look at boost multi array? (
http://www.boost.org/doc/libs/1_43_0/libs/multi_array/doc/user.html*)

*
--snip--
    *  Boost 1.34 or-later. Although VTK/vtkSNL build with Boost 1.33, the
n-way arrays have a dependency on Boost 1.34.
    * Build vtkSNL with VTKSNL_N_WAY_ARRAYS set to ON.
--snip--

In hopes I can try vtkDenseArray<double>

-- 
Brian J. Davis

-- 
Brian J. Davis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100514/8b8837b1/attachment.htm>


More information about the vtkusers mailing list