Circles with holes (rings) ROI manager issue

Tags: #<Tag:0x00007fd541fa07d0> #<Tag:0x00007fd541fa0640> #<Tag:0x00007fd541fa0398> #<Tag:0x00007fd541fa0230>


Hi to all,
I think that someway this problem was already solved, but I do not find it.
I want to have the rois of the attached images,
as you can see for the fully connected rings the ROI is a circle without the interior hole (the rois in red).
Is it already implemented a parameters/algorithms (I am using jython to do this analysis, but I could change) to addres to ring roi extraction?
I have tried with the “include holes” check box in Analyze Particles but without good results.

thank you,
Emanuele Martini

Remove overlap and out-of-focus particles

Hi Emanuele,
I think that for the two last ROIs you have the same problem, just that since the rings are open, it can make a normal ROI. If you zoom, I’m sure that you will find that the ROI is made of a single perimeter rather than 2 separate ones.

As a “hacky” solution you can.

  1. Use Analyze particles with “include holes” unticked and with Show “Count Masks”
  2. After this, go through the detected objects and for each object i:
  3. Set a threshold between i-0.5 and i+0.5 on the count masks image
  4. Run “Create Selection”
  5. Add to Manager

This worked for me in IJ1 macro so perhaps it will be useful to you.


yes yes the problem is that the green ones are open rings, and it works :slight_smile:
when it is a close it has problem.
Yes I am thinking to some tricks like yours, but maybe there is an option (or plugin) somewhere to have directly the rings rois without “workaround”.
Thank you very much in any case,
have a nice day


at the end I use your workaround it works well.
But I really think that if some developer of imagej group had time to work on it , it could be a very nice feature to have directly rois that has the boundaries of “ring” shapes.

Thank you very much,
have a nice day


Hi Olivier

Thank you for your solution! I was very happy when it worked on a test image, but I found that it only works well with few ROIs, but starts misbehaving if you have a lot of ROIs (500+) and it seems to be putting 2 or 3 ROIs in each bin. I’ll probably end up splitting the images, but it gets even uglier… :frowning:

If all people want is to get measurements of the mean/area, then another workaround is to tick “Display Results” in “Analyze Particles” and then in “Analyze”>“Set Measurements” redirect the measurement to be done in your original image/image of interest.

BUT it looks like myself and Emmanuele need the actual ROIs for further manipulations. Since the “Display Results” works as it should excluding the holes from selection and from measurement (compare results generated from “display results” to results from selecting the ROI in the ROI manager generated by exactly the same action and pressing “Measure”), I conclude that the behaviour of ROI selection is a glitch and it needs to be fixed before damage is done to results of unsuspecting scientists. I am new here and I was wondering, whether it is possible to tag developers to this forum to address this, or we have to go through the normal route of submitting tickets, etc.?


Dear @BrainPatcher,

Initially I would have said that the issue is due to the fact that “Count Masks” could have an 8-bit output, but the output is 16-bits when there are more than 255 objects.

Now I know that when setting the threshold manually (Via the Set Button), the displayed threshold is incorrect, but “Create Mask” works…

Can you place here one of the binary masks you obtain before running the hacky solution? Ideally one with more than 255 objects?