Filling holes in an Roi within a plug-in

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

Filling holes in an Roi within a plug-in

Rats
Hi All!

If you try to get the polygon for an roi that's full of holes, you're returned its bounding box. This is perfectly reasonable, but I'm after the outermost outline. Would there be any straightforward way to fill these holes prior to requesting the polygon within a plug-in? The only way I can see involves creating an ImagePlus from ImageProcessor returned by roi.getMask(), then using IJ.run(imp, "Fill Holes"), but it seems an overly complicated way of doing things.

Thanks in advance,

Luke.
Reply | Threaded
Open this post in threaded view
|

Re: Filling holes in an Roi within a plug-in

Michael Schmid
Hi Luke,

if you find nothing else, you could try the following (I don't know whether it works):
Assuming you have a ShapeRoi, use
  Roi[] rois = getRois();((ShapeRoi)roi).getRois()
and then loop through the rois to see whether there is an entry with the same bounding box as the original roi. This one should be the outline.
If it works in principle and you don't get a proper match, this would indicate that it is not a single particle with holes but several particles.

Michael
________________________________________________________________
On Mar 19, 2015, at 14:46, Rats wrote:

> Hi All!
>
> If you try to get the polygon for an roi that's full of holes, you're
> returned its bounding box. This is perfectly reasonable, but I'm after the
> outermost outline. Would there be any straightforward way to fill these
> holes prior to requesting the polygon within a plug-in? The only way I can
> see involves creating an ImagePlus from ImageProcessor returned by
> roi.getMask(), then using IJ.run(imp, "Fill Holes"), but it seems an overly
> complicated way of doing things.
>
> Thanks in advance,
>
> Luke.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Filling holes in an Roi within a plug-in

Rats
Thanks Michael!

I'll give that a try!