Re: Detect ROI at edge of image?
Posted by Rasband, Wayne (NIH/NIMH) [E] on Feb 28, 2011; 8:05pm
URL: http://imagej.273.s1.nabble.com/Detect-ROI-at-edge-of-image-tp3685525p3685526.html
On Feb 28, 2011, at 9:59 AM, gibberfish wrote:
> Hello,
>
> I have an image containing a number of ROIs. Now I want to detect (and
> remove) all the ROIs touching the edge of the image. Is there a quick way to
> do this?
>
> The ROI manager shows them having a line running on the edge of the image
> which might be useful for this, but I don't know if this is actually part of
> the ROI or just automatic "closing" of the ROI.
Here is a macro that removes all the ROIs in the ROI Manager that are touching the edge of the image:
n = roiManager("count");
for (i=n-1; i>=0; i--) {
roiManager("select", i);
getSelectionBounds(x, y, w, h);
if (x<=0||y<=0||x+w>=getWidth||y+h>=getHeight)
roiManager("delete");
}
-wayne