How do I find the number of circles in an image? I’ve given the code I used and output image below
clc;
close all;
clear all;
a=imread(‘C:UsersHemaDesktopnonemptylot.jpg’);
b=imread(‘C:UsersHemaDesktopemptylot.jpg’);
[x,y]= size(a);
[c d]=size(b);
e=rgb2hsv(a);
f=rgb2hsv(b);
subplot(1,2,1)
imshow(e);
title(‘HSV of Nonempty’);
centers = imfindcircles(e,[20 20]);
[centers,radii] = imfindcircles(e,[5 15]);
[centers,radii,metric] = imfindcircles(e,[5 15]);
BW=size(viscircles(centers, radii,’EdgeColor’,’b’));
STATS = regionprops(BW,’EquivDiameter’);
subplot(1,2,2)
imshow(f);
title(‘HSV of empty’);
centers = imfindcircles(f,[20 20]);
[centers,radii] = imfindcircles(f,[5 15]);
[centers,radii,metric] = imfindcircles(f,[5 15]);
BW=size(viscircles(centers, radii,’EdgeColor’,’b’));
STATS = regionprops(BW,’EquivDiameter’);
disp(STATS);clc;
close all;
clear all;
a=imread(‘C:UsersHemaDesktopnonemptylot.jpg’);
b=imread(‘C:UsersHemaDesktopemptylot.jpg’);
[x,y]= size(a);
[c d]=size(b);
e=rgb2hsv(a);
f=rgb2hsv(b);
subplot(1,2,1)
imshow(e);
title(‘HSV of Nonempty’);
centers = imfindcircles(e,[20 20]);
[centers,radii] = imfindcircles(e,[5 15]);
[centers,radii,metric] = imfindcircles(e,[5 15]);
BW=size(viscircles(centers, radii,’EdgeColor’,’b’));
STATS = regionprops(BW,’EquivDiameter’);
subplot(1,2,2)
imshow(f);
title(‘HSV of empty’);
centers = imfindcircles(f,[20 20]);
[centers,radii] = imfindcircles(f,[5 15]);
[centers,radii,metric] = imfindcircles(f,[5 15]);
BW=size(viscircles(centers, radii,’EdgeColor’,’b’));
STATS = regionprops(BW,’EquivDiameter’);
disp(STATS); clc;
close all;
clear all;
a=imread(‘C:UsersHemaDesktopnonemptylot.jpg’);
b=imread(‘C:UsersHemaDesktopemptylot.jpg’);
[x,y]= size(a);
[c d]=size(b);
e=rgb2hsv(a);
f=rgb2hsv(b);
subplot(1,2,1)
imshow(e);
title(‘HSV of Nonempty’);
centers = imfindcircles(e,[20 20]);
[centers,radii] = imfindcircles(e,[5 15]);
[centers,radii,metric] = imfindcircles(e,[5 15]);
BW=size(viscircles(centers, radii,’EdgeColor’,’b’));
STATS = regionprops(BW,’EquivDiameter’);
subplot(1,2,2)
imshow(f);
title(‘HSV of empty’);
centers = imfindcircles(f,[20 20]);
[centers,radii] = imfindcircles(f,[5 15]);
[centers,radii,metric] = imfindcircles(f,[5 15]);
BW=size(viscircles(centers, radii,’EdgeColor’,’b’));
STATS = regionprops(BW,’EquivDiameter’);
disp(STATS); circles, finding number of objects, image processing MATLAB Answers — New Questions