2
$\begingroup$

Let's say I have an image like this one, and have masked it so all yellow pixels are 1 and all black pixels are 0. I would like to (1) fit the largest possible circles containing solely yellow pixels inside the yellow blobs; multiple circles may fit in irregular blobs, (2) from all such circles, identify which has the biggest radius, and (3) find the location of its center. What image processing techniques can I use for this? I am familiar with some morphological operations (like these), but can't get to where I want to go yet.

$\endgroup$
2
$\begingroup$

do a distance transform. you'll see why that's a good idea: for every pixel you get the shortest distance to a border. that's exactly the radius of an inscribed circle.

from this, just find the pixel with the largest value.

if you're curious, throw a "non-maximum suppression" on it. that is a kind of "morphological" kernel operation where you set a pixel to 0 if any neighbor has a strictly larger value.

enter image description here

$\endgroup$
  • $\begingroup$ Very cool! Color in your plot shows distance to border, right? The distance transform is built into Matlab so it will be easy for me to try, mathworks.com/help/images/ref/bwdist.html $\endgroup$ – KAE May 25 '18 at 19:23
  • $\begingroup$ I tried this on a group of images like this and it worked well. $\endgroup$ – KAE May 25 '18 at 20:59
  • $\begingroup$ For those analyzing this kind of image with the Matlab implementation (bwdist): You will want to make the pixels around the edge of the mask 'false', so that you force blobs that extend out of the image to end at the image edge. Otherwise you will get a lot of center points falling on the edges and corners. $\endgroup$ – KAE May 29 '18 at 15:14
0
$\begingroup$

First, the question you mentioned in the comments contains good ideas for sure.

Secondly, an approach using morphological operations is to implement an iterative algorithm that performs successive Morphological Erosions using a disk as the structural element. The idea is to begin with a large radius disk (half of the smallest image dimension is sufficient) and to stop when the returned image contains at least one white pixel (assuming that 1 is white). All of them are the centers of the biggest circles that can be contained in your "yellow zone".

This approach may be quite slow as it tests all the possibilities. Optimisation is certainly possible (dichotomy method maybe).

Hope it will help.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.