Login  Register

Re: how to access the ROI programmatically?

Posted by Gabriel Landini on Jul 03, 2006; 9:20pm
URL: http://imagej.273.s1.nabble.com/how-to-access-the-ROI-programmatically-tp3702303p3702304.html

> I need to do a check for whether or not a certain point/pixel coordinate is
> contained in the ROI.
> My code is of the form
> for all pixels, if pixels is in ROI, do stuff
> The ROI is a path resulting from freehand selection.
>
> I was not able to find such a function in the API documentation. Is there a
> function like the one I'm describing? Any suggestions on how to implement
it?

There is a method in Roi.java called "contains" which perhaps does what you
need (not entirely sure).
However if you have many pixels this may be slow.

Alternatively you could create a binary image that has just the filled ROI,
then use this image to direct the analysis (scan this image and all set
pixels give you the coordinates of the pixels in the original that need to be
processed).

I hope it helps.

Gabriel