Login  Register

Calling ImageJ plugins directly in MATLAB

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Calling ImageJ plugins directly in MATLAB

ddickinson
Hi everyone,

I'm using Michael Schmid's "Find Maxima" plugin to locate peaks in some images.  This is part of a complicated image processing pipeline that runs in MATLAB, so I've been calling the command using
MIJ.run('Find Maxima...')
This works, but the problem is that MIJ seems to require that the image is displayed in order for the "Find Maxima" command to work (if I change to non-displaying mode, I can see that the ImagePlus object is there - i.e. the image is open - but the command returns error "No Images Open").  I think it should be possible to use the Java functionality of MATLAB to call functions directly, without using MIJ (or using MIJ only to generate the ImagePlus object, not to run the command), but I can't seem to find any documentation on this.  Does anyone know how to do it?  

Thanks,
Dan Dickinson
University of North Carolina
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Calling ImageJ plugins directly in MATLAB

ctrueden
Hi Dan,

> I think it should be possible to use the Java functionality of MATLAB
> to call functions directly, without using MIJ (or using MIJ only to
> generate the ImagePlus object, not to run the command), but I can't
> seem to find any documentation on this.

If you are looking to evaluate MATLAB code from within an ImageJ plugin or
other Java code, MATLAB provides an interface for doing this as long as
your program was launched from inside the MATLAB JVM. You can read more
about it on the excellent "Undocumented Matlab" blog [1].

If you are looking to call ImageJ/Java code from your MATLAB script, this
is actually much simpler. Simply embed the calls to fully qualified Java
class methods directly in your scripts. As an example, the Bio-Formats
bfopen.m script [2] does so extensively to provide image I/O for the
formats it supports. MATLAB takes care of transparently converting between
Java primitive types and arrays and its own matrices and cell structures.

Regards,
Curtis

[1] http://undocumentedmatlab.com/blog/jmi-java-to-matlab-interface/
[2]
https://github.com/openmicroscopy/bioformats/blob/v4.4.6/components/bio-formats/matlab/bfopen.m


On Fri, Apr 12, 2013 at 6:00 AM, ddickinson <[hidden email]> wrote:

> Hi everyone,
>
> I'm using Michael Schmid's "Find Maxima" plugin to locate peaks in some
> images.  This is part of a complicated image processing pipeline that runs
> in MATLAB, so I've been calling the command using This works, but the
> problem is that MIJ seems to require that the image is displayed in order
> for the "Find Maxima" command to work (if I change to non-displaying mode,
> I
> can see that the ImagePlus object is there - i.e. the image is open - but
> the command returns error "No Images Open").  I think it should be possible
> to use the Java functionality of MATLAB to call functions directly, without
> using MIJ (or using MIJ only to generate the ImagePlus object, not to run
> the command), but I can't seem to find any documentation on this.  Does
> anyone know how to do it?
>
> Thanks,
> Dan Dickinson
> University of North Carolina
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Calling-ImageJ-plugins-directly-in-MATLAB-tp5002621.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Calling ImageJ plugins directly in MATLAB

dscho
Hi,

On Wed, 17 Apr 2013, Curtis Rueden wrote:

> > I think it should be possible to use the Java functionality of MATLAB
> > to call functions directly, without using MIJ (or using MIJ only to
> > generate the ImagePlus object, not to run the command), but I can't
> > seem to find any documentation on this.
>
> If you are looking to evaluate MATLAB code from within an ImageJ plugin
> or other Java code, MATLAB provides an interface for doing this as long
> as your program was launched from inside the MATLAB JVM. You can read
> more about it on the excellent "Undocumented Matlab" blog [1].
>
> If you are looking to call ImageJ/Java code from your MATLAB script,
> this is actually much simpler. Simply embed the calls to fully qualified
> Java class methods directly in your scripts. As an example, the
> Bio-Formats bfopen.m script [2] does so extensively to provide image I/O
> for the formats it supports. MATLAB takes care of transparently
> converting between Java primitive types and arrays and its own matrices
> and cell structures.

Note that the majority of the code in MIJ deals with converting data
structures back and forth between ImageJ images (not Java arrays) and
Matlab arrays.

Feel free to reinvent the wheel.

:-)

Ciao,
Dscho

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html