Code covered by the BSD License  

4.66667

4.7 | 6 ratings Rate this file 50 Downloads (last 30 days) File Size: 254 KB File ID: #32344
image thumbnail

Hardware accelerated 3D viewer for MATLAB

by

 

26 Jul 2011 (Updated )

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

| Watch this File

File Information
Description

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 http://rsb.info.nih.gov/ij/index.html). It has a clever plugin system that allows users to extend it with new functionalities.

Fiji (Fiji is Just ImageJ, http://fiji.sc/) 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,

Acknowledgements

This file inspired Stack Reg Wrapper.

MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (20)
09 Apr 2014 Jean-Yves Tinevez

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

08 Apr 2014 Emanuele Martini

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

15 Feb 2014 ted p teng

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!

15 Feb 2014 ted p teng  
24 Oct 2013 Soonam

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.

30 May 2013 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.

18 Aug 2012 Zhiyong

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
javax.media.j3d.IllegalRenderingStateException: GL_VERSION
at javax.media.j3d.NativePipeline.createNewContext(Native Method)
at javax.media.j3d.NativePipeline.createNewContext(NativePipeline.java:2775)
at javax.media.j3d.Canvas3D.createNewContext(Canvas3D.java:4914)
at javax.media.j3d.Canvas3D.createNewContext(Canvas3D.java:2440)
at javax.media.j3d.Renderer.doWork(Renderer.java:917)
at javax.media.j3d.J3dThread.run(J3dThread.java:275)
Exception occurred in RenderingErrorListener:
java.lang.RuntimeException
at ij3d.ImageWindow3D$ErrorListener.errorOccurred(ImageWindow3D.java:310)
at javax.media.j3d.VirtualUniverse.notifyRenderingErrorListeners(VirtualUniverse.java:1329)
at javax.media.j3d.NotificationThread.processNotifications(NotificationThread.java:90)
at javax.media.j3d.NotificationThread.run(NotificationThread.java:107)
// 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.
Exiting.

17 Jul 2012 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.

15 Jun 2012 Carlos  
09 Dec 2011 Jean-Yves Tinevez

@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.

08 Dec 2011 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 universe.show() 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 javax.media.j3d is sealed
at java.net.URLClassLoader.defineClass(URLClassLoader.java:234)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at com.mathworks.jmi.CustomURLClassLoader.findClass(ClassLoaderManager.java:754)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at com.mathworks.jmi.CustomURLClassLoader.findClass(ClassLoaderManager.java:754)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at ij3d.ImageWindow3D.<init>(ImageWindow3D.java:64)
at ij3d.Image3DUniverse.show(Image3DUniverse.java:195)

06 Nov 2011 Ran Shadmi

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

Ran

06 Nov 2011 Jean-Yves Tinevez

@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?
Thanks.

05 Nov 2011 Jean-Yves Tinevez

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

05 Nov 2011 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!
Ran

06 Aug 2011 Jean-Yves Tinevez

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

04 Aug 2011 Johannes Schindelin

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

29 Jul 2011 Peter

Okay, just emailed you the output from running InstallJava3D.

28 Jul 2011 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.

28 Jul 2011 Peter

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.

Updates
27 Jul 2011

Minor tyop in the title.

04 Aug 2011

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

13 Aug 2011

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.

Contact us