Ask Your Question

Rasmus's profile - activity

2018-08-28 21:08:22 -0600 received badge  Notable Question (source)
2017-03-01 05:41:03 -0600 received badge  Popular Question (source)
2014-11-05 09:06:17 -0600 commented question Largest enclosed area

No one? Is the question maybe unclear?

2014-11-04 07:22:02 -0600 asked a question Largest enclosed area

Hi all,

I have a binary image containing objects similar to the ones to the left in the figure below. I would now like to perform some operation to get to the shapes to the right (or the corresponding contour). The red dot represents a starting point if it would be necessary for the workflow (preferentially not).

image description

A) and B) illustrates that I would like to remove parts outside of the "largest enclosed area", basically the interior of the circle

In C) this area would be larger because there is no line between the circles (and I drew some thick part to illustrate that this is not based on the contours but on the binary image)

D) shows that if there is no "enclosed area" it shouldn't return anything

Any suggestion on how to approach this would be very much appreciated!

Some stuff I've thought about is: -Flood fill from different starting points and keep largest region -Some graph theory method about enumerating circular paths and then select among them -Start by "eroding" the shape from the outside according to some rules until only the interior region remains -Cleverly cut the shape and keep track of the intersections and thereby deduce something -Maybe it can be gotten from the contour function somehow?

This is somewhat time critical, so faster approaches would be better than slower

Thanks!

2014-10-28 00:13:56 -0600 received badge  Good Answer (source)
2014-10-28 00:13:56 -0600 received badge  Enlightened (source)
2014-10-27 04:18:12 -0600 received badge  Scholar (source)
2014-10-26 08:13:42 -0600 received badge  Nice Answer (source)
2014-10-26 05:51:13 -0600 received badge  Teacher (source)
2014-10-26 05:33:44 -0600 commented answer Detecting overlapping circles

Sure, see above

2014-10-26 05:18:56 -0600 received badge  Self-Learner (source)
2014-10-26 05:18:34 -0600 received badge  Editor (source)
2014-10-26 04:58:15 -0600 answered a question Detecting overlapping circles

I came up with a solution which worked well for me. Hough transform, and the variant described above, was useful for finding the number of overlapping circles and their approximate centers, but significant optimization was required afterwards for finding the exact sizes. I also found that it was difficult to find parameter settings which worked well for all scales (in particular small circles partly overlapping large ones). Instead I did like this:

1) Get the outer contours for each connected component 2) Get the convex hull for the contour 3) Calculate the distance to the hull for each point in the contour 4) Local maxima in the distances correspond to intersection points between the circles. Split the contour at these points and fit a circle to each segment

I found this to be an easier and faster solution, but most importantly it seems to be much more robust. It typically finds all relevant circles, but there is a risk of duplicates which should be filtered out afterwards.

Here's an example:

Original

image description

After circle detection (green objects with black fitted circles)

image description

2014-10-25 12:48:59 -0600 commented answer Detect contour with mask

Thanks! I was maybe not very clear in the first post, but one problem is that the text may be only partly overlapping with the objects of interest. If I inderstood you correctly a text component would be colored white if some part of it touched an object of interest. That is not what I'm looking for since it would change the shape of the object. Inpainting looks interesting, but I'm afraid it would also distort the shapes. Is it possible to perform set operations like union, setdiff and so on on contours?

2014-10-25 05:20:06 -0600 asked a question Detect contour with mask

Hi all,

I'm detecting circular objects in an image by first getting a binary map based on color deviation from the background and then getting the contours of the connected components (and then a bunch of other stuff). The thing is that there may be text written over the objects, which results in that the objects are split into several parts. The text can be small and just inside some connected component or it may be many times larger than the components. I can generate a mask for the text based on its color. I want to ignore the text somehow, but I'm not quite sure how.

image description

In this case the fitting for three connected components has failed due to overlapping text. In the leftmost case no fitting could be made (no black circles around object) since the "O" excludes a piece of the object. In the middle case there are many small incorrect circles fitted because the contour gets fragmented. In the right case the fitting is bad due to the overlapping text.

I see three possible ways forward:

-Deal with this when first getting the connected components

-Merge contours which are connected by the text mask

-Get contours which include the text and then modify the contours afterwards

Any help with this would be much appreciated! Maybe there is even some clever OpenCV function for this? Thanks!

2014-09-30 21:28:51 -0600 received badge  Student (source)
2014-09-30 08:06:48 -0600 commented question Detecting overlapping circles

Sorry, small number of closely aligned points I mean. So that only some small fraction of the circle is actually covered.

2014-09-30 08:05:34 -0600 commented question Detecting overlapping circles

...parameter space. If so then my problem can maybe be reduced to how to fit circles to a small number of points. The reason I use larg(er) random segments is that the quadratic fitting tends to favor very small circles when only a small number of pixels are used. Is there maybe a clever way of doing this? I see unpleasent words such as eigenvectors coming up.. :)

2014-09-30 08:02:39 -0600 commented question Detecting overlapping circles

Thanks for your suggestions! It was not stated in the original question, but I actually use an elliptical fit just as you suggested in order to screen out the shapes which are simple circles. The above workflow is only applied to complex shapes.

I looked up Hough transform at Wikipedia, and it sounds rather similar to what I do. I take a random segment, fit a circle to it, clusters in parameter space and use the median in each cluster as representative. Hough transform iterates over each pixel, fits a circle to it and its surrounding and counts how ofter the resulting parameter combination occurs. The main difference seems to be that Hough does this for each pixel while I do it for some random number of segments. The counting also indicates that Hough requires some bounds on the...

2014-09-30 01:14:44 -0600 asked a question Detecting overlapping circles

Hi all,

This is my first post in this forum, and it could be that i'm totally in the wrong place. But i give it a shot..

I'm a biologist tasked with detecting yeast colonies on a nutrient plate. The colonies are circular and about 3-5 mm in diameter. My problem comes from that several colonies might overlap so that you have shapes consisting of 2-5 partially overlapping circles. I need to detect the position and size of all such circles.

I know nothing about computer vision/pattern recognition, but this is my naive approach so far:

1) Find the edges of the shapes. I do this by calculating the color variance for each pixel and its surrounding neighbours. This gives a map where edges have high values and the background has zero (after some filtering)

2) Find all the individual shapes (connected non-zero regions in the map above)

3) a) For each shape select a random connected subset of the shape (corresponding to a partial circle segment). Fit a circle to these points by least squares. b) Repeat a) several times to get coverage for the whole edge of the shape. c) Cluster the calculated circle geometries from above. The number of clusters should then give the number of overlapping circles and the mean och each cluster should give the geometry.

4) (Optional. Use the input from 3) to perform a constrained heuristic optimization to fine tune the fittings.)

This whole thing works reasonably well if the circles are few and only slightly overlapping, but not well for complex shapes with several circles. It's also slow because of the fitting of random arcs. It also feels like too much of a home made brute force solution and i'm sure there are many more clever ways to do it. For example, could you count the number of times some fitted shape (spline or something) goes from concave to convex as you go along the edge of the shape? That should give the number of circles and their approximate intersection points.

All of this is done in Matlab, but anything else would work as well. Here is an image which shows how the colonies might look: http://medicine.emory.edu/id/labs/lyon/yeast.bmp

Any help is very welcome! Feeling rather lost in this field :)