Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
我有这段代码,我需要输入一个图像并输出一个带有三角形,正方形,圆形,星形或矩形的字符串。对完成这个项目有什么帮助吗?
“仅黑白图像 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 更多&回答... |
![]() |
![]() |