collect all same coins in each figure

2 ビュー (過去 30 日間)
Tu Nguyen
Tu Nguyen 2022 年 4 月 13 日
回答済み: Image Analyst 2023 年 9 月 7 日
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

回答 (1 件)

Image Analyst
Image Analyst 2023 年 9 月 7 日
This is just what my tutorial does. See my Image Segmentation Tutorial in my File Exchange:
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.

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by