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.
collect all same coins in each figure
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!