How to Use ImageJ-MATLAB


Even with the documentation, it took me quite some time to figure out how to launch ImageJ-MATLAB on MATLAB. The bottom line is that the ImageJ.m file that is bundled with Fiji is not functional on purpose; you are supposed to update the file through the automatic updater. And the documentation above doesn't mention it!

  1. Install Fiji
  2. Use MATLAB R2017b or later, which uses JAVA 1.8+ as ImageJ/Fiji does.

    • Use the following command to check the JAVA version of MATLAB matlab version -java
  3. Executing the following commands

addpath 'D:\Fiji.app\scripts\' % depends your Fiji installation
ImageJ

will bring a dialog which prompts you to add an update site http://sites.imagej.net/MATLAB/.

  1. This means that, following the instruction of the web page, you go to Fiji > Update...
  2. Once checking status is done, open Manage update sites

  3. Tick ImageJ-MATLAB

  4. And then click Apply changes on ImageJ Updater

  5. This will literally update and replace the existing, non-functional ImageJ.m file in the scripts folder with the genuine one.

Now ImageJ.m runs in MATLAB

>> ImageJ
--------------------------------------------------------------
ImageJ-MATLAB 0.7.2: MATLAB to ImageJ Interface
--------------------------------------------------------------
JVM> Version: 1.8.0_121
JVM> Total amount of memory: 796160 Kb
JVM> Amount of free memory: 295252 Kb

-- Welcome to ImageJ-MATLAB --
ImageJ-MATLAB consists of an extensible set of commands for passing information between ImageJ and MATLAB.
See the individual sections below for a list of available commands.

For more information and examples see:
    http://imagej.net/MATLAB-Scripting

--- MATLAB Command Plugins ---

-- ImageJ MATLAB commands --

Usage: IJM.[command]
    help - prints a brief description of available commands
    getDataset - creates a MATLAB matrix from the active ImageJ image
    getDatasetAs(name) - creates a MATLAB matrix from the active ImageJ image, and assigns it to the specified variable name
    show(name) - takes the MATLAB matrix with the specified name and displays it as an image



--------------------------------------------------------------
Status> ImageJ is running.
--------------------------------------------------------------
log4j:WARN No appenders could be found for logger (loci.formats.ClassList).
log4j:WARN Please initialize the log4j system properly.

PS. After this, I extensively edited the official documentation, so it should be much easier now.