Re: Can a RoiManager ROI act as a button?

Posted by Adrian Daerr-2 on
URL: http://imagej.273.s1.nabble.com/Can-a-RoiManager-ROI-act-as-a-button-tp5019935p5019939.html

Hi Ard, Herbie, and all,

In Java you could add a MouseListener[1] to the image window, and in the
MouseClicked function ask the RoiManager which ROI has been selected
(getSelectedIndex method[2]). Then check whether the mouse coordinates
(as given by the MouseEvent) are indeed within that ROI (otherwise it
means that the RoiManager has not changed the selection upon the most
recent click - e.g. because that click went outside any ROI).
hth

Adrian


[1]
https://docs.oracle.com/javase/7/docs/api/java/awt/event/MouseListener.html
[2]
https://imagej.nih.gov/ij/developer/api/ij/plugin/frame/RoiManager.html#getSelectedIndex--

On 01/23/2018 06:04 PM, Herbie wrote:

> Good day Art,
>
> please consult the built-in macro functions
> <https://imagej.nih.gov/ij/developer/macro/functions.html>
>
> especially
>
> "*getCursorLoc(x, y, z, modifiers)*
> Returns the cursor location in pixels and the mouse event modifier
> flags. The z coordinate is zero for 2D images. For stacks, it is one
> less than the slice number. Use toScaled(x,y) to scale the coordinates.
> For examples, see the GetCursorLocDemo and the GetCursorLocDemoTool
> macros."
>
> and
>
> "*Roi.contains(x, y)*
> Returns "1" if the point x,y is inside the current selection or "0" if
> it is not. Aborts the macro if there is no selection. Requires 1.49h.
> See also: selectionContains."
>
> HTH
>
> Herbie
>
> :::::::::::::::::::::::::::::::::::::::
> Am 23.01.18 um 16:40 schrieb A. Jonker:
>> In an image, we have a macro that detects areas that are candidates
>> for furhter analysis.
>> Each candidate is outlined with a RoiManager's ROI, with a ROI Number.
>> Each image has about 60 candidates, of which by eye we can quickly
>> identify 2 or 3 real ones.
>> The other candidates are bogus but as such very hard to recognise by
>> Image Analysis.
>>
>> We have a function available to handle that ROI, and remove it from
>> the candidates list.
>> Rinse and repeat until no candidates are left. A special 'Finished'
>> ROI can be added...
>>
>> When clicking on a ROI it becomes selected in the Roi Manager.
>> Can we automatically launch a macro/call a function by that click?
>> I was thinking along the lines as roiManager("onClick",someFunction()).
>> I know a ^ can be used for macro activation on keystroke.
>> Can that be done with the mouse too? It would dramatically speed up
>> our analysis.
>>
>> Ard
>>
>> ________________________________
>>
>> AMC Disclaimer : https://www.amc.nl/disclaimer
>>
>> ________________________________
>>
>> --
>> 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