Small issue with the RoiManager

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Small issue with the RoiManager

CARL Philippe (LBP)
Dear all,

Please consider the plugin below :

 

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
Reply | Threaded
Open this post in threaded view
|

Re: Small issue with the RoiManager

Yuekan Jiao-2
Hi,

After loading imp2, you can bring imp1 to the front by using:

IJ.SelectWindow(title1);

Hope it will work for you.

Yuekan


On Fri, Mar 18, 2016 at 6:17 AM, Philippe CARL <[hidden email]>
wrote:

> Dear all,
>
> Please consider the plugin below :
>
>
>
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Small issue with the RoiManager

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by CARL Philippe (LBP)
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
Reply | Threaded
Open this post in threaded view
|

Re: Small issue with the RoiManager

CARL Philippe (LBP)
In reply to this post by Yuekan Jiao-2
Dear Yuekan,
Your suggestion can unfortunately not be appllied, since I'm having a mouselistener and mousemotionlistener active on the imp2 which listeners are modifying features within the imp1.
Thanks a lot Wayne for adding this new method within the RoiManager class.
My best regards,
Philippe

Le Vendredi 18 Mars 2016 17:57 CET, Yuekan Jiao <[hidden email]> a écrit:

> Hi,
>
> After loading imp2, you can bring imp1 to the front by using:
>
> IJ.SelectWindow(title1);
>
> Hope it will work for you.
>
> Yuekan
>
>
> On Fri, Mar 18, 2016 at 6:17 AM, Philippe CARL <[hidden email]>
> wrote:
>
> > Dear all,
> >
> > Please consider the plugin below :
> >
> >
> >
> > 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





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