How to detect the center of a cercle in an RGB image.

2 views (last 30 days)
Hello, i am trying to find an algorithm to detect a circle in an image, i used the imfindcircles function with the proper radius paramter but it won't find the circles. I am working on the the attached picture. i want to detect the inner the circle of the piece located in the bottom of the image, or the big circle that contain the small one.

Answers (1)

Jayanti
Jayanti on 26 Mar 2025
Hi Theodor,
I have used “imfindcircles” function to detect the circle in the provided image.
Please refer to the below code for more details:
A= imread('WebcamImg-1.jpg');
imshow(A)
[centers, radii] = imfindcircles(A,[50 200],'ObjectPolarity','dark','Sensitivity',0.9);
hold on;
imshow(A);
viscircles(centers, radii, 'EdgeColor', 'b');
hold off;
I have set the object polarity to “dark” as the circular object is darker compared to the background of the image and increased the sensitivity from 0.85(default) to 0.9.
Below is the output image I am getting:
To get more information on the name value arguments of this function please refer to the below link:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!