[ImageJ-devel] Status and API of ROIs in ImageJ2 ?

Adrian Daerr adrian.daerr at univ-paris-diderot.fr
Sat Aug 15 06:14:13 CDT 2015


Hello,

I am seizing a major rewrite of a plugin as an opportunity to switch
from ImageJ1 to ImageJ2, also to avoid concurrency issues[*], and now
lots of questions come up. Some concern the way ROIs are handled. What
has happened in this regard since
   http://imagej.net/ROIs
was last updated ?

[*] cf discussion on the ImageJ list archived at
http://imagej.1557.x6.nabble.com/ExtendedPlugInFilter-GenericDialog-and-synchronization-td5013333.html

Here are two concrete questions:

1) My plugin relies on a rectangular ROI being drawn on the image to
know which area to include in the computation. How do I draw this ROI
once I have loaded the image as a dataset in the main() method that is
used for testing purposes ?

public static void main(final String... args) throws Exception {
     final String testImagePath = "testImage.jpg";

     // Launch ImageJ as usual.
     final ImageJ ij = net.imagej.Main.launch(args);

     // Open test image.
     final Dataset dataset = ij.dataset().open(testImagePath);

     // display the dataset
     ij.ui().show(dataset);

     // create rectangular ROI
     //imp.setRoi(120,60,340,420);// How to do this on a dataset ?

     // Launch the "Foo_Bar" command.
     ij.command().run(Foo_Bar.class, true);
}

(alternatively, how would I generate a new dataset, or I guess something 
like a "View" in ImageJ2 terminology, of the ROI sub-image of the 
original dataset ? I could then substitute the original dataset with 
this sub-image and have the plugin operate on the whole image by default)

2) The plugin preview generates overlays using java.awt.geom.Path2D,
java.awt.geom.Area and java.awt.Shape, which are then converted via
ij.gui.ShapeRoi() and ij.gui.Overlay(), assembled with overlay.add(),
and drawn using imp.setOverlay(). Is there a new IJ2-way to do this
(especially since the cited web page (rightly) insists on separation
of selection and visualisation shapes) ?

TIA,
Adrian



More information about the ImageJ-devel mailing list