Rahul galgali
Rahul galgali

Reputation: 763

Find circles in image without using Hough transform

I want to find the circles in the below image.I tried using OpenCV's Hough circle detection but it is not giving the proper results.

Is there any other way to find circles?

enter image description here

Here is sample code

vector<Vec3f> circles;
Mat src_gray,te; 
cvtColor(tImg, src_gray, CV_BGR2GRAY);
GaussianBlur(src_gray, src_gray, Size(9, 9), 2, 2);
Canny(src_gray, te, 40, 240, 3);
/// Apply the Hough Transform to find the circles 
HoughCircles(te, circles, CV_HOUGH_GRADIENT, 1, te.rows / 10, 120, 9, 5, 25); 

Upvotes: 2

Views: 2860

Answers (1)

Deepak
Deepak

Reputation: 1088

Take contour,
1. find the centroid of the contour
2. find distance from the centroid to each contour pixels.
3. if this distance is almost same then it will be a circle.

See This link

Upvotes: 1

Related Questions