MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   MATLAB识别几何图形 (https://www.labfans.com/bbs/showthread.php?t=22305)

poster 2019-12-01 02:11

MATLAB识别几何图形
 
我有这段代码,我需要输入一个图像并输出一个带有三角形,正方形,圆形,星形或矩形的字符串。对完成这个项目有什么帮助吗?

“仅黑白图像

clear all close all im=imread('circulo_fr.jpg'); img=rgb2gray(im); BW=im2bw(img); stats=regionprops(BW,'Perimeter','Area','Centroid','BoundingBox'); figure,imshow(BW); hold on for k=1:length(stats) thisboundingbox=stats(k).BoundingBox; if stats(k).Area>10000 retangulo('Position',[thisboundingbox(1), thisboundingbox(2), thisboundingbox(3), thisboundingbox(4)], 'EdgeColor','r','LineWidth',2); else retangulo('Position',[thisboundingbox(1), thisboundingbox(2), thisboundingbox(3), thisboundingbox(4)], 'EdgeColor','b','LineWidth',2); end if stats(k).Perimeter^2/stats(k).Area > 18 text(stats(k).Centroid(1),stats(k).Centroid(2),'Triangulo','Color','r'); elseif stats(k).Perimeter^2/stats(k).Area < 14.3 text(stats(k).Centroid(1),stats(k).Centroid(2),'Circulo','Color','g'); else text(stats(k).Centroid(1),stats(k).Centroid(2),'Quadrado','Color','b'); end

[url=https://stackoverflow.com/q/59118748]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 21:23

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.