Adem
imfindcircles works fine if you change the parameter Sensitivity from the default 0.85 to 0.95
Follow these steps:
1.
Capture
A=imread('im1.jpg');title('initial image');
ColorList={'Red' 'Green' 'Blue'};
N=256;
gr=0:1/(N-1):1;
figure(1);imshow(A);
2.
split RGB
N=255;
cMap=zeros(N,3);cMap(:,1)=gr;
figure(2);hr=imshow(ind2rgb(A(:,:,1),cMap));title(ColorList{1});
cMap=zeros(N,3);cMap(:,2)=gr;
figure(3);hg=imshow(ind2rgb(A(:,:,2),cMap));title(ColorList{2});
cMap=zeros(N,3);cMap(:,3)=gr;
figure(4);hb=imshow(ind2rgb(A(:,:,3),cMap));title(ColorList{3});
.
3.
Keep the Blues
B=hb.CData;
B1=B(:,:,1);B2=B(:,:,2);B3=B(:,:,3);
nonzeros(B1)
nonzeros(B2)
4.
Extreme contrast with the right threshold of 0.2
If you try theshold 0.1 the area of interest is too large. With threshold above 0.3 N would turn pitch black.
N=B3
N(N>0.2)=255
N(N<0.2)=0
figure(5);imshow(N)
.
5.
Apply imfindcircles to the extreme contrast image N, not the initial image.
A bit of manual trimming is needed:
With too wide range of radii [1 40] only small circles are caught, not the big one you want:
[centers, radii, m] = imfindcircles(N,[1 40],'Sensitivity',0.95);
viscircles(centers, radii,'EdgeColor','b');
with radii range [10 40] the camera circle is successfully caught, but there are 2 additional undesired circles.
[centers, radii, m] = imfindcircles(N,[10 40],'Sensitivity',0.95);
viscircles(centers, radii,'EdgeColor','r');
the best set of parameters is:
[centers, radii, m] = imfindcircles(N,[15 40],'Sensitivity',0.95);
viscircles(centers, radii,'EdgeColor','g');
.
if you find these lines useful would you please mark my answer as Accepted Answer?
To any other reader, if you find this answer of any help please click on the thumbs-up vote link,
thanks in advance for time and attention
John BG