File Exchange

image thumbnail

Hardware accelerated 3D viewer for MATLAB

version 1.4 (254 KB) by

A set of demonstrations that show how to install and use an accelerated 3D viewer for MATLAB.

9 Ratings



View License

ImageJ is an image processing software, very popular in the Life-Science field. If you are a master student, a PhD or a postdoc in Biology, there is a very good chance that ImageJ is installed on your computer.

ImageJ is developed mainly by Wayne Rasband, and is written in Java (see It has a clever plugin system that allows users to extend it with new functionalities.

Fiji (Fiji is Just ImageJ, is a distribution of ImageJ, that includes (amongst other things) a lot of plugins, some useful libraries and an updater to keep everything up to date.

Amongst other things, it is made to facilitate inter-operability with other softwares. For instance, it offers scripting facilities using popular languages such as Python, Ruby, Clojure, Beanshell, Javascript, etc. It also ships with Miji, a set of utilities made to ease its interaction with MATLAB. Since ImageJ is written in Java, it can be called directly from within MATLAB, and be used as a supporting image visualization, processing or analysis tool.

In this demo bundle, we demonstrate how to use Fiji to get a very nice, hardware accelerated, 3D viewer in MATLAB.

Note on updates on these demos files: If you have already installed Fiji and set the paths as explained in this demo introduction, you do not have to re-download them from the FEX. All you have to do is launch Fiji and run the updater. The demo files, which are part of the Fiji distribution, will be updated as well,

Comments and Ratings (24)

Ilya Belevich


Great code!!!
I need to add x_label and y_label in ImageJ 3D Viewer. Would you please help me how can do it?


George (view profile)

I am running MATLAB 2014b on Mac OS X 10.9.5 (Mavericks) and was able to start Fiji from MATLAB using Miji and transfer an image opened by Fiji to a MATLAB array, until I installed InstallJava3D.

Now I get
Exception in thread "Startup Class Loader" java.lang.NoSuchMethodError:



even before running Miji. Once I do run Miji, I can no display transfered image arrays using imshow, instead MATLAB crashes. It seems that Java3D has broken something in the MATLAB install.

If I try to run Matlab3DViewerDemo_1.m,

I get the following error:
/Users/my_name/.ImageJ_3D_Viewer.props (No such file or directory)

Has anyone else experienced this? Any solution?

The author here,
For some reason it does not seem to work with MATLAB R2014a on MaxOSX. Can someone confirm?

Very nice!
I have a questions:
o) is it possible to set the transparency?
thank you,

ted p teng

ted p teng (view profile)

ted p teng

ted p teng (view profile)

Thanks for sharing! Miji worked like a charm. It enabled me to batch process with functions in imagej wothout manully switching back n forth between matlab and imagej!


Soonam (view profile)

It was great documents from Matlab to 3D Viewer. I am curious that can I link another ImageJ/fiji plug-ins such as volume viewer using this MIJ?

If yes, How can I link them? I saw the demo files and use ij3d.Image3DUniverse() to open 3-D viewer. But in volume viewer, I don't think we use ij3D class.

Can you let me know any directions to solve this problem??

Thank you.

Urs Utzinger

While the export of data from Matlab to 3D Viewer is well documented the path backward is difficult to figure out.

1) I have not figured out how to import a rendered scene as an image.

2) In the 3D Viewer one can change the view with the mouse but I have not figured out how to get the actual 3D transformation matrix back to Matlab.

3) While one can zoom with the Mouse scroll button, there appears to be no such function available to control the viewer from Matlab. A workaround is to compute the 3D transformation matrix for objects in Matlab but I could only make that work for objects and not for the view of the Universe.

Comment) The Transformation Matrix in Java3d is not the usual Rotation*Scaling*Translation. Translation is appended as 4th column.


When I attempt to run any of the demos, a blank ImageJ 3D Viewer window appears. Clicking any of the dropdown menus on the ImageJ 3D Viewer leaves "ghosts".

When I close the ImageJ 3D Viewer window, the following error occurs:

// Error message begin GL_VERSION
at Method)
Exception occurred in RenderingErrorListener:
at ij3d.ImageWindow3D$ErrorListener.errorOccurred(
// Error message ends.

I am using MATLAB 2012a. I have already run the InstallJava3D.m file and got the following output:
Testing if Java3D is already installed...
Java3D is already installed.
Installed version is 1.5.
This is good enough, you have nothing to do.

Jean-Yves Tinevez

@Shalin: the sealing violation exception is caused by Lion being shipped with an old version of Java3D. If you just run the InstallJava3D script in MATLAB, this will fix the problem.


Carlos (view profile)

@Shalin: Hi Shalin! Could you contact me off-list so that we can try to fix this? This is a rather obscure error, at least to me. Best, jy.

Shalin Mehta

Hello, Nice work. I am running into problems with MATLAB R2011b on MAC OS Lion (Java VM Version: Java 1.6.0_29-b11-402-11M3527 with Apple Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode) .

When I try to execute from the first demonstration, I encounter following error. It looks like a permission related issue, but I cannot figure out how to resolve this.

Error using ij3d.Image3DUniverse/show
Java exception occurred:
java.lang.SecurityException: sealing violation: package is sealed
at Method)
at com.mathworks.jmi.CustomURLClassLoader.findClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(
at java.lang.ClassLoader.defineClass(
at Method)
at com.mathworks.jmi.CustomURLClassLoader.findClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at ij3d.ImageWindow3D.<init>(

Ran Shadmi

Looks like you fixed it!
Thanks a lot!
Here comes your 5-stars rating...


@Ran: I think I found the problem.
Could you update Fiji, make sure scripts/Miji.m is listed in the update, relaunch Fiji (mandatory), then try again?

@Ran: Hi, could you contact me via e-mail so that we sort this out?

Ran Shadmi

I would love to give it 5-stars rating but unfortunately I keep running into the same problem:
??? Undefined variable "ij3d" or class "ij3d.Image3DUniverse".

Error in ==> Matlab3DViewerDemo_1 at 110
universe = ij3d.Image3DUniverse();
For example, I use the demo:
>> Matlab3DViewerDemo_1
works perfect, also returns "nFrames = 1". Next I do:
>> clear variables
>> Matlab3DViewerDemo_1
And then I get the error above. I managed to re-run the demo successfully only if I close the Matlab session and open a new one.
I use windows 7 64-bit and Matlab R2010a.

I will appreciate any help, thanks!

It is fixed; you just have to update Fiji. I added a check for the bin folder, where, on windows platform, the dlls go.

Is this resolved? Otherwise, the exact and full error message would be quite useful for people who try to help... :-)

Okay, just emailed you the output from running InstallJava3D.

Jean-Yves Tinevez

Hi Pete,
Can you send me the Matlab output so that I can try and fix this?
Also, the m-files are in the fiji/scripts folder.

Followed the directions, but the Java3D library won't install. IsJava3DInstalled returns 1, but something isn't right. Not sure what's up. I get an error at the call to ij3d in the first demo.

Also, .m files would be preferable to .html files for the demo.



Added a new demo file, relating how to generate surface plots: a 3D surface is generated from a 2D image, interpreting pixel value as elevation. Thanks to the recent work of Johannes on Fiji 3D viewer.


Changed the InstallJava3D script for windows installations.
Updated the demo introduction as well.
Thanks to Peter Beemiller.


Minor tyop in the title.

MATLAB Release
MATLAB 7.12 (R2011a)

Inspired: stackRegWrapper, Microscopy Image Browser (MIB)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video