collect all same coins in each figure
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear all;
I want to collect all same value coins in each figure. For example, all 1 cent coin in 1 figure, all 5 cent coin in 1 figure. How can I do that?
Really appreciate for your help
clc;
close all;
clear;
I = imread("money.png");
Ig = rgb2gray(I);
imshow(Ig);
Ib = imbinarize(Ig,'global');
imshow(Ib);
se = strel('disk',2);
Ih = imerode(Ib,se);
Ih = Ib - Ih;
imshow (Ih);
If = imfill(Ih,'holes');
label = bwlabel(If);
max(max(label));
im1 = (label ==1);
figure;
imshow(im1)
for i = 1:max(max(label));
[row, col] = find(label ==i);
len = max(row)-min(row)+2;
breath = max(col)-min(col) +2;
target = uint8(zeros([len breath]));
sy = min(col) - 1;
sx = min(row) - 1;
for j = 1:size(row,1);
x = row(j,1) - sx;
y = col(j,1) - sy;
target(x,y) = I(row(j,1),col(j,1));
end
mytitle = strcat('Object Number:',num2str(j));
figure;
imshow(target);
end
0 Kommentare
Antworten (1)
Image Analyst
am 7 Sep. 2023
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, like dimes or nickels only.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!