0
$\begingroup$

I a new to MATLAB and i am trying to apply circle fitting technique to the following image.

Image

enter image description here

Expected Output

enter image description here

I used the following code with no luck:

[centers, radii] = imfindcircles(W,[30 65],'ObjectPolarity','bright');
figure,imshow(W);% title('Sobel gradient');
viscircles(centers,radii,'Color','b');

Note that the circle size can vary between picture

Any suggestions.

$\endgroup$
1
$\begingroup$

imfindcircles can take in other "Name, Value" pairs as parameters. In your case, a really helpful one is the Sensitivity parameter. I would change your first line to include this (also note that 'bright' is the default value for 'ObjectPolarity', so I took it out). The value `0.95' here can be tuned to get more or fewer circles identified.

[centers, radii] = imfindcircles(W, [30 65], 'Sensitivity', 0.95);

Since you mentioned circles may vary between pictures, it would be beneficial use some other parameters to get better results across the set of images. Check out the MATLAB documentation online for specifics.

$\endgroup$
  • $\begingroup$ i doesn't work also. Circles are not shown in the figure $\endgroup$ – Hadi Dec 31 '17 at 8:31
  • $\begingroup$ Well, for different images you will have to change that parameter to get the result you want. I gave 0.95 here just as an example, but running a quick script on MATLAB it seems like Sensitivity of 0.96 actually gives better results. So try replacing the 0.95 with 0.96 instead. $\endgroup$ – goldrik Dec 31 '17 at 9:42
  • $\begingroup$ now it is working $\endgroup$ – Hadi Dec 31 '17 at 9:54

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.