Re: Small issue with the RoiManager

Posted by Rasband, Wayne (NIH/NIMH) [E] on
URL: http://imagej.273.s1.nabble.com/Small-issue-with-the-RoiManager-tp5015935p5015944.html

On Mar 18, 2016, at 9:17 AM, Philippe CARL <[hidden email]> wrote:
>
> Dear all,
>
> Please consider the plugin below :

Upgrade to the latest ImageJ daily build (1.50i7) and use rm.rename(index,newName) to rename the ROI. Here is a JavaScript example:

  rm = RoiManager.getInstance();
  if (rm==null)
     rm = new RoiManager();
  imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");
  imp.show();
  rm.addRoi(new Roi(23,17,72,93));
  index = rm.getCount()-1;
  rm.rename(index, "roi");
  roi = rm.getRoi(index);
  roi.setStrokeColor(Color.red);

-wayne


> import ij.*;
>
> import ij.process.*;
>
> import ij.gui.*;
>
> import java.awt.*;
>
> import ij.plugin.*;
>
> import ij.plugin.frame.RoiManager;
>
>
>
> public class My_Plugin implements PlugIn {
>
>                public void run(String arg) {
>
>                               RoiManager rm = RoiManager.getInstance();
>
>                               if (rm==null) rm = new RoiManager();
>
>                               ImagePlus imp1 =
> IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");
>
>                               imp1.show();
>
>                               imp1.setRoi(23,17,72,93);
>
>                               ImagePlus imp2 =
> IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");
>
>                               imp2.show();
>
>                               rm.addRoi(imp1.getRoi());
>
>                               rm.select(rm.getCount() - 1);
>
>                               rm.runCommand("Rename"   , "roi");
>
>                }
>
> }
>
>
>
> In this code, I use the line " rm.select(rm.getCount() - 1);" in order to be
> able to be able to rename the last added Roi within the RoiManager with the
> line " rm.runCommand("Rename"   , "roi");".
>
> But in the same time the line " rm.select(rm.getCount() - 1);" will add the
> given Roi to the imp2 picture (since imp2 is the selected window).
>
> Thus is there a way, having imp2 as selected window, to add a Roi from imp1
> to the RoiManager and rename it (and change its color,.) without adding this
> same Roi to imp2?
>
> I thank you very much in advance for your hints about this issue and wish
> you a nice week-end.
>
> My best regards,
>
> Philippe
>
>
>
> Philippe CARL
>
> Laboratoire de Biophotonique et Pharmacologie
>
> UMR 7213 CNRS - Université de Strasbourg
>
> Faculté de Pharmacie
>
> 74 route du Rhin
>
> 67401 ILLKIRCH
>
> Tel : +33(0)3 68 85 41 84
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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