# Circle fitting for a binary image

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

Image

Expected Output

I used the following code with no luck:

[centers, radii] = imfindcircles(W,[30 65],'ObjectPolarity','bright');


Note that the circle size can vary between picture

Any suggestions.

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.

• i doesn't work also. Circles are not shown in the figure