Code covered by the BSD License  

Highlights from
vol3d v2

4.8

4.8 | 5 ratings Rate this file 101 Downloads (last 30 days) File Size: 3.4 KB File ID: #22940
image thumbnail

vol3d v2

by Oliver Woodford

 

10 Feb 2009 (Updated 16 Apr 2011)

3-d volume (voxel) rendering

| Watch this File

File Information
Description

An update to Joe Conti's popular vol3d function, allowing voxel colors and alpha values to be defined explicitly. Functionality is increased, but the function is entirely backwards compatible.

In cases where voxels can be any RGB color, use:
   vol3d('CData', cdata);
where cdata is an MxNxPx3 array, with RGB color along the 4th dimension. In cases where color and alpha values are highly independent, specify an MxNxP alphamatte as follows:
   vol3d('CData', cdata, 'Alpha', alpha);

This function amends the original (as little as possible) with the full permission of Joe Conti. The original function comes with some additional tools for editing colormaps and alphamaps which are not included in this version. See:
http://www.mathworks.com/matlabcentral/fileexchange/4927

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (15)
09 Jul 2009 Jan Van den Bulcke

Wonderful!

31 Dec 2009 Greg Siegle

Marvelous! Gorgeous 3d renderings of MRIs. Esp. in bone colormap.

08 May 2010 Matthias Pospiech

Wonderful script to generate 3D Volume plots.

However I need to set the axis values other than just the sizes of the data matrix.

How can one specifiy the axis (in x,y and z) for this plot?

10 May 2010 Oliver Woodford

Matthias: Unfortunately specifying different axis values isn't currently possible using this function. It is straightforward to implement though. You just need to change lines 121, 124 and 127 to achieve the desired results.

18 Apr 2011 Oliver Woodford

Matthias: The latest version allows you to set axis limits.

24 May 2011 Maxwell  
14 Aug 2011 harish raj

matlab collapses if i run vol3d code

15 Aug 2011 Oliver Woodford

The rendering method does stress MATLAB's rendering pipeline, so large volumes can slow down your machine significantly. Good graphics hardware helps a bit. Smaller datasets do too.

05 Dec 2011 Wilson

Nice code, but in my case, I can only render a 3D image but can not save the image.

When I use command:
h = vol3d('CData',Y); saveas(h,'Image3D.fig');
Matlab displays it's a 'Invalid handle'

If I save the image directly from figure, it displays:

Warning: Variable 'hgS_070000' cannot be saved to a MAT-file
whose version is older than 7.3.
To save this variable, use the -v7.3 switch.
Skipping...
> In hgsave at 93
  In general\private\saveasfig at 7
  In saveas at 126
  In filemenufcn>localSaveExportHelper at 203
  In filemenufcn>localSaveExport at 316
  In filemenufcn at 56

And only a figure frame is saved instead of the actual image.

any ideas?

05 Dec 2011 Oliver Woodford

Wilson: saveas requires a figure handle. vol3d returns a structure, hence the first error. The second error is due to the figure being too large. Try:
   hgsave(gcf, 'Image3D.fig', '-v7.3');

05 Dec 2011 Wilson

The hgsave command works, many thanks

20 Dec 2011 Jean-Philippe

This script works great to display MRI-like 3d images.

In the case that I have a logical 3d array (ie: a segmentation mask of an anatomical structure from an MRI), how can I use vold3d to only show the resulting mask? I am able to display my MRI model, but when I just want to display the mask I get a blank plot.

I = a [MxNxP] matrix for my MRI [grayscale values 0-255]
J = a [MxNxP] matrix for my mask [logical 0 or 1]

figure;
vol3d('cdata',I, 'texture','3D'); %this works
vol3d('cdata',J, 'texture','3D'); %this is blank
view(3);

Thank you for your help.

03 Feb 2012 Mohamed Nassar

Hello oliver, I used your code to display a 3D volume raw data, using this command "H= vol3d('cdata',datafile); it just displayed the 2D images on top of each other, looks like only a one 2d image, the datafile format is (x,y,z), where x is the number of frames, y *z is the 2d image's size, also at the end of the module, you load a mat file "mri.mat" which is not included, could you please advise me with that? thank you so much, you reply is highly appreciated

03 Feb 2012 Oliver Woodford

Mohamed: If you run the demo you should discover that mri.mat is included with MATLAB. The 3D data is displayed using textured-mapped 2D planes, as described in the help. Call
   view(3)
to see a 3D view of the data.

03 Feb 2012 Mohamed Nassar

Oliver, Thank you so much, it works fine with me

Please login to add a comment or rating.
Updates
16 Apr 2011

Avoid destroying other vol3d objects when rerendering. Added a demo.

Tag Activity for this File
Tag Applied By Date/Time
volume viewer Oliver Woodford 10 Feb 2009 11:24:03
data visualization Oliver Woodford 10 Feb 2009 11:24:04
volume Oliver Woodford 10 Feb 2009 11:24:04
voxel Oliver Woodford 10 Feb 2009 11:24:04
graphics Oliver Woodford 10 Feb 2009 11:24:04
rendering Oliver Woodford 10 Feb 2009 11:24:04

Contact us at files@mathworks.com