coins.png how to find the smallest coin in a image and display it alone in a separate window?

조회 수: 48 (최근 30일)
how to find the smallest coin in the image below and display it alone in a separate window

채택된 답변

DGM
DGM 2022년 1월 10일
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개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by