资源简介
这个是我们期末的大作业,做了很久才做出来的,绝对正确,是对一幅图里不同图形的识别,希望大家能用的上
代码片段和文件信息
bw=imread(‘223.bmp‘);
bw=imcomplement(bw); %反白
bw=im2bw(bwgraythresh(bw)); %转化为灰度图
imshow(bw);
[BL] = bwboundaries(bw‘noholes‘); %检测边界
figureimshow(bw);
% Display the label matrix and draw each boundary %填充颜色
figureimshow(label2rgb(L @jet [.5 .5 .5]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:2) boundary(:1) ‘w‘ ‘LineWidth‘ 2)
end
stats = regionprops(L‘Area‘‘Centroid‘);
threshold = 0.8; %阈值设定
% loop over the boundaries %计算面积与周长关系“metric
for k = 1:length(B)
% obtain (XY) boundary coordinates corresponding to label ‘k‘
boundary = B{k};
% compute a simple estim
评论
共有 条评论