File Exchange

image thumbnail

VOXview

version 2.0.0 (528 KB) by Tim
Voxelized volume visualization for 3D and 3D RGB arrays

14 Downloads

Updated 26 Mar 2021

View Version History

View License

VOXview is an easy-to-use function for visualizing small 3D scalar or RGB (i.e. MxNxO x3) arrays. This function was specifically designed to give the user independent control of voxel alpha, intensity, and color values, something that is currently not possible when using MATLAB's "volshow" command.

Example:
VOXview(rand(50, 50, 50, 3)); % Generate volume filled with voxels having random RGB values.

Additionally, the function gives users direct control of:
- Colormaps (for scalar fields)
- Patch properties (e.g. edge colors, reflectivity options)
- Alpha threshold (faces below this value are left un-drawn)
- Multiple types of transparency computation methods
- Voxel size
- Bounding boxes
And lastly it provides the patch-handle for the final object for efficient manipulation after the fact.

Run VOXview_demo.m for demonstrations of different input options.
Run Lamp_demo for an animation demonstration exploiting voxel patch handles.

Important performance note:
VOXview has been updated to use texture mapping, so like vol3d it can now render much larger volumes (e.g. 500 voxels on edge). This enables simple colormap updating as well, however there may be some backward compatibility issues. To improve backward compatibility set texturemapping to false, which will render the volume using a single call to patch as done originally. This enables some other features to be used and simplifies patch property modification using the returned handle, however the rendering slows down considerably for large volumes and in this mode is not suggested for volumes larger than 100 pixels on edge.

Acknowledgements:
vol3d v2 inspired the inclusion of texture mapping as an option.

Cite As

Tim (2021). VOXview (https://www.mathworks.com/matlabcentral/fileexchange/78745-voxview), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (6)

Tim

Ok... I just looked this up and apparently R2020b turbo has been added to Matlab's list of colormaps. The crash makes sense if you are using R2020a (turbo shouldn't be recognized) but if you are running R2020b then it should not crash, even if turbo is not listed in the workspace

Ankur Gupta

Thanks a lot. It works perfectly now. Just one minor issue I observed which might be unrelated to VOXview. It doesn't seem to work with "turbo" colormap. The error I get says "Unrecognized function or variable turbo". I am using Matlab 2020a.

Tim

It does normalize, however since the color of each voxel face is being explicitly defined, the colormap property of the figure axis is unrelated to the voxel colors (e.g. try VOXview(randn(30, 30, 30), 'colormap', jet) and then call colorboar: the colormap will still be Parula). If you want to add a colorbar with the relevant color and axes for your 3D data do the following: 1) Call VOXview using your preferred colormap, 2) caxis([<<your data range here>>]), set(gca, 'colormap', <<your colormap here>>); colorbar

Modifying the axis CLim and Colormap properties to reflect user selections is a great idea though and I will add that as an update so all you will need to do is call colormap (for 3D vs. 4D RGB cubes)

Tim

Modifying the axis CLim and Colormap properties to reflect user selections is a great idea though - I will add that as an update

Ankur Gupta

Extremely useful script. However, I have a question. Are the values in the tensor being renormalized? The maximum value in my tensor is 0.6; however, according to the colorbar scheme, it corresponds to a value of 1.0.

Ankur Gupta

MATLAB Release Compatibility
Created with R2020a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: vol3d v2

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!