How do I find the number of circles in an image? I've given the code I used and output image below
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
clc; close all; clear all; a=imread('C:\Users\Hema\Desktop\nonemptylot.jpg'); b=imread('C:\Users\Hema\Desktop\emptylot.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);
0 comentarios
Respuestas (1)
Jayanti
el 24 de Mzo. de 2025
Hi Soundarya,
“imfindcircles” function returns the centers and radii of the detected circles. The number of circles is simply the length of the centers array. “centers” is a matrix where each row represents a circle.
[centers1, radii1, metric1] = imfindcircles(e, [5 15]);
numCirclesNonEmpty = size(centers1, 1);
[centers2, radii2, metric2] = imfindcircles(f, [5 15]);
numCirclesEmpty = size(centers2, 1);
The below code
size(centers, 1);
will return the size of the first dimension of the “centers” matrix. Which corresponds to the number of detected circles.
1 comentario
Image Analyst
el 24 de Mzo. de 2025
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!