MATLAB: Image correction to find circles

circlediffernceimageimage processingImage Processing Toolboximfindcircle

I have this image and I want to find circle using imfindcircle, this image is from my camera, sometimes because of ambient light the blue circle gets a bit darker and imfindcircle don't work, is there anyway that i could correct this image to get a brighter circle so imfindcircle won't fail!

Best Answer

Adem
My solution works without any particular color.
I opted to work on blue because (wrongly) assumed the images you work on would be mostly blue.
But there is no need to use colors at all
look:
1.
Capture image
A=imread('im1.jpg');title('initial image');
figure(1);imshow(A);
2.
Ignore colors, just black and white
A2=A(:,:,1)+A(:,:,2)+A(:,:,3);
figure(2);h2=imshow(A2);
.
3.
get the extreme contrast image, experts also call this type of image binary image. I tried different thresholds between 10 and 250 and all seem to work ok
N=h2.CData
N(N>10)=255
N(N<10)=0
figure(3);imshow(N)
4.
Like before, my solution works with the right Sensitivity of 0.95 that I found for you
[centers, radii, m] = imfindcircles(N,[15 40],'Sensitivity',0.95);
viscircles(centers, radii,'EdgeColor','g');
.
5.
Applying found circle on initial figure, checking there is no offset
figure(1);viscircles(centers, radii,'EdgeColor','g');
.
no colors, yet we get the sought circle.
would you please be so kind to mark my answer as accepted answer
appreciating time and attention
awaiting answer
John BG