3D Visualization for Matlab
Transcript of 3D Visualization for Matlab
matVTK
3D Visualization for Matlab
Erich Birngruber, René Donner, Georg Langs
Computational Image Analysis and Radiology LabMedical University of Vienna, Austria
http://www.cir.meduniwien.ac.at/
CSAIL, Massachusetts Institute of Technology, USA
Dienstag, 29. September 2009
Motivation
2
Previous work
• Gobbi et al. 2008: Simulink Libraries for Visual Programming of VTK and ITK
Need
• Work on (large) medical datasets
• Need for “visual debugging” / big picture
• Easy usability for the Matlab userExample from work of S. Witoszynskyj
Dienstag, 29. September 2009
Motivation
Matlab
• Rapid prototyping / algorithm development
• Limited visualization for 3D data
3
Dienstag, 29. September 2009
Motivation
Matlab
• Rapid prototyping / algorithm development
• Limited visualization for 3D data
VTK
• Powerful, good performance
• Platform independent
3
Dienstag, 29. September 2009
Outline
• Development foundations
• Resulting Framework
• Use cases
Dienstag, 29. September 2009
Foundations
• Mex interface allows access to C/C++ libs
- Use Matlab memory managment
- Mex entry point function
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]){ ... }
• VTK “pipes & filters” concatenate data processing
5
Dienstag, 29. September 2009
Obstacles
• Keeping state:
no direct support for handles in Mex
• VTK rendering loop interferes with Matlab
6
Dienstag, 29. September 2009
matVTK Framework
• Handle based:
implicit creation, automatic destruction
• Imitates Matlab plot commands:
prefixed with vtk...
vtkplotpoints(pointset)
vtkquiver(points, vectors)
7
Dienstag, 29. September 2009
Parameters
• No code generation: explicit mapping
• Easily extendable
• Basic settings mapping:
8
Dienstag, 29. September 2009
Parameters
• No code generation: explicit mapping
• Easily extendable
• Basic settings mapping:
VTKscalar valuetriplet valuedifferent modes (Constants)
8
Dienstag, 29. September 2009
Parameters
• No code generation: explicit mapping
• Easily extendable
• Basic settings mapping:
VTKscalar valuetriplet valuedifferent modes (Constants)
mapping
8
Dienstag, 29. September 2009
Parameters
• No code generation: explicit mapping
• Easily extendable
• Basic settings mapping:
VTKscalar valuetriplet valuedifferent modes (Constants)
Matlab5[1, 2, 3]“String”
mapping
8
Dienstag, 29. September 2009
matVTK Framework
9
Matlab
VTK
Input
Data
Numeric
Output
Handle
Graphic primitives
points
lines
surfaces
volumes
Algorithms
triangulation
pointselection
Visual
output
Function
callsHandle
Dienstag, 29. September 2009
Primitives
10Example from work of E. Dittrich
Dienstag, 29. September 2009
Primitives
• Points
10Example from work of E. Dittrich
Dienstag, 29. September 2009
Primitives
• Points
10
• Lines
Example from work of E. Dittrich
Dienstag, 29. September 2009
Primitives
• Points
10
• Lines
• Volumes
• Meshes (surfaces)
Example from work of E. Dittrich
Dienstag, 29. September 2009
Primitives
• Points
10
• Lines
• Volumes
• Meshes (surfaces)
• Vectors (as arrows)
Example from work of E. Dittrich
Dienstag, 29. September 2009
Primitives
• Points
10
• Lines
• Volumes
• Meshes (surfaces)
• Vectors (as arrows)
• Tensors
Example from work of E. Dittrich
Dienstag, 29. September 2009
Combining Primitives
• Combinations of primitives can construct complex scenes
11
Example from work of E. Schwartz
Dienstag, 29. September 2009
Additional Functionality
• Widgets for data inspection & annotation
• Cropping
• Labels
• Axes
• Data export
• Restore scenes
12
Dienstag, 29. September 2009
Example
% plot and save components to handlehv = vtkplotvolume(volume,‘SoftSkin’)hm = vtkplotmesh(vertices, faces ‘color’, [0 0 1])% crop volume and mesh with plane widgetvtkcrop(hv, ‘plane’)vtkcrop(hm)% show axesvtkgrid% interactive display, free resourcesvtkshowvtkdestroy
13
Dienstag, 29. September 2009
Example
% plot and save components to handlehv = vtkplotvolume(volume,‘SoftSkin’)hm = vtkplotmesh(vertices, faces ‘color’, [0 0 1])% crop volume and mesh with plane widgetvtkcrop(hv, ‘plane’)vtkcrop(hm)% show axesvtkgrid% interactive display, free resourcesvtkshowvtkdestroy
13
Dienstag, 29. September 2009
Performance
100 130 160 190 220 2500
10
20
30
40
50
60
70
cube sidelength
se
cs
matVTK
Matlab
Isosurfacing for different volume sizes14
Dienstag, 29. September 2009
Availability
• Developed on MacOS X 10.5
• Linux 32bit, 64bit
• Windows XP, Vista, 7
15
as platform independent as Matlab and VTK
Dienstag, 29. September 2009
Outlook
• Streaming visualization
• Saving widget states
• Remove scene objects
• Event recording / movies
16
Example from work of G. Langs
Dienstag, 29. September 2009
Thanks
• Available online:
http://www.cir.meduniwien.ac.at/matvtk/
• Feedback and ideas [email protected]
17
Dienstag, 29. September 2009