Login  Register

Get ROI from mouse click

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

Get ROI from mouse click

Cspr
Hey ImageJ users

I'm writing a stand-alone application in which I call ImageJ functions. So far it has gone mostly without any major issues, but there is one problem. After running Analyze Particles what is the procedure for letting the user clicking on a ROI in the image, and have that selection highlighted in the ROImanager?

At the present I was thinking using a MouseListener and get the coordinates of the mouseclick and then do some search (havent figured out how) through the ROI's and check which one (if any) the click applies to.

But perhaps someone else can give me a better idea?

Thank you :)
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Get ROI from mouse click

EHB2010
I haven't much experience of the ROI Manager but have played around with ROIs. I'd go for a MouseEvent like you suggested with a really simple static factory method such as (untested):

import ij.gui.Roi;
import ij.plugin.frame.RoiManager;

class checkIfMouseClickIsInTheRois {

        static void checkTheseSpecificMouseClicks (int xMouseClick, int yMouseClick) {
                Roi[] arrayRoi = RoiManager.getInstance().getRoisAsArray();
                for (int i = 0 ; i < arrayRoi.length ; ++i) {
                        if (arrayRoi[i].contains(xMouseClick, yMouseClick)) {
                                RoiManager.getInstance().select(i);
                        }
                }
        }
}