How to count the amount of small squares in this picture?
Ältere Kommentare anzeigen
Akzeptierte Antwort
Weitere Antworten (3)
KALYAN ACHARJYA
am 15 Dez. 2024
Approximate Way:
image_input=imread('image file name');
image_bw=imbinarize(rgb2gray(image_input));
cc=bwconncomp(image_bw);
number=cc.NumObjects;
However, you can obtain the exact value by incorporating additional morphological and logical statements.
1 Kommentar
xie
am 17 Dez. 2024
Image Analyst
am 15 Dez. 2024
0 Stimmen
It's a generic, general purpose demo of how to threshold an image to find blobs, and then measure things about the blobs, and extract certain blobs based on their areas or diameters.
BW=imbinarize(im2gray(imread('image.png')));
BW([1,end],:)=0;
BW(:,[1,end])=0;
BW=imopen(BW,ones(2));
nv=numAlong(BW,1)
nv =
45
nh=numAlong(BW,2)
nh =
65
total=nv*nh
total =
2925
function out=numAlong(BW,dim)
s=reshape( sum(BW,3-dim),[],1);
m=bwareaopen(s>max(s)/3,8);
out=bwconncomp(m).NumObjects;
end
Kategorien
Mehr zu Template Matching finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


