Detect ROI at edge of image?

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

Detect ROI at edge of image?

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

Re: Detect ROI at edge of image?

Michael Schmid
Hi,

you may write a short macro for this.

As a starting point, e.g., use the 'Fill' macro in
   http://rsb.info.nih.gov/ij/macros/RoiManagerMacros.txt
to see how to write a loop over all rois in the RoiManager.

In the loop, use getSelectionBounds(x, y, width, height).
If x=0, y=0, x+width=getWidth() or y+height=getHeight(), the roi  
touches the edge.

Hope this helps,

Michael
________________________________________________________________

On 28 Feb 2011, at 15:59, 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.
Reply | Threaded
Open this post in threaded view
|

Re: Detect ROI at edge of image?

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by gibberfish
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