coins.png how to find the smallest coin in a image and display it alone in a separate window?
42 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
how to find the smallest coin in the image below and display it alone in a separate window
0 Kommentare
Akzeptierte Antwort
DGM
am 10 Jan. 2022
Something like this:
A = imread('coins.png');
m = bwareaopen(A>80,100);
% get areas, sort, get bounding box
C = regionprops(m,'area','boundingbox');
area = vertcat(C.Area);
[~,idx] = min(area);
bbox = C(idx).BoundingBox;
% get subimage, display
thiscoin = imcrop(A,bbox);
imshow(thiscoin)
I chose to interpret "smallest" as meaning "has the least area". If you wanted some measure of diameter, you'd have to get the appropriate region property and sort it.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!