Ask Your Question

Detecting circles/ellipse/whatever in an image

asked 2016-03-06 03:51:27 -0500

BartBB2 gravatar image

I need to detect the amount of dots/circles/ellipse as I said in the title.

The quality of the image is as shown below (the circles aren't that round either which makes it hard on HoughCircles to detect it with my current settings or any other settings for that matter. I need a reliable way of detecting the amount of dots.. I have searched the internet for weeks and have finally given up. I could really use directions or if anyone volunteers to write the code for me, I won't mind) :

Any help is appreciated. I write my code in C++.

edit retag flag offensive close merge delete



I don't really think that HoughCircles can't detect that, but anyway... given your settings, a simple thresholding+findContours will almost directly give you the circles blob. You can add some kind of shape analysis to check circularity

LorenaGdL gravatar imageLorenaGdL ( 2016-03-06 04:00:23 -0500 )edit

What is "findContours"? Have I mentioned I'm new to opencv?

BartBB2 gravatar imageBartBB2 ( 2016-03-17 10:43:19 -0500 )edit

2 answers

Sort by » oldest newest most voted

answered 2016-03-06 09:48:06 -0500

Amr gravatar image

I have not done this exactly before but how I would do it is to capture your image then process it thresholding to prepare for contour extraction. once you have done that find the length of contours. according to the results of your image processing so far you can specify that the contours are closed or else you will need to combine close enough contours. Next find the centroid of your contours and view the results if in centre of circles then you can find the radius and knowing the circumference (length of contour) divide contour length by 2пr for a circle the value should be close to 1.

edit flag offensive delete link more


Honestly, I am quite new to OpenCV and I have no idea how to do half of the things you said. Links to examples/tutorials or explaining it will really be appreciated!

BartBB2 gravatar imageBartBB2 ( 2016-03-17 10:42:47 -0500 )edit

answered 2016-03-07 10:41:36 -0500

jmbapps gravatar image

Houghcircles works fine. If you want to count the half circles that are partially covered, then you will need to do some more image processing. I ran your first photo through my Find Circles app and these were the results. image description

edit flag offensive delete link more


And this was made using HoughCircles or some other technique of finding circles/blobs?

BartBB2 gravatar imageBartBB2 ( 2016-03-17 10:40:49 -0500 )edit


jmbapps gravatar imagejmbapps ( 2016-03-30 10:48:24 -0500 )edit

Can you send me the HoughCircles part of the code? Could really be useful for me. I still haven't figured it out.

BartBB2 gravatar imageBartBB2 ( 2016-03-31 12:43:50 -0500 )edit

2, 40, 35, 46, 10, 25 is what worked in my app. Hope this helps.

jmbapps gravatar imagejmbapps ( 2016-03-31 16:49:52 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-03-06 03:51:27 -0500

Seen: 789 times

Last updated: Mar 07 '16