-
大小: 1KB文件類型: .m金幣: 1下載: 0 次發(fā)布日期: 2021-01-04
- 語言: Matlab
- 標(biāo)簽:
資源簡介
這個(gè)是我們期末的大作業(yè),做了很久才做出來的,絕對正確,是對一幅圖里不同圖形的識(shí)別,希望大家能用的上
代碼片段和文件信息
bw=imread(‘223.bmp‘);
bw=imcomplement(bw);??????????????%反白
bw=im2bw(bwgraythresh(bw));??????%轉(zhuǎn)化為灰度圖
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;????????????????????????????????%閾值設(shè)定
%?loop?over?the?boundaries????????????????????%計(jì)算面積與周長關(guān)系“metric
for?k?=?1:length(B)
??%?obtain?(XY)?boundary?coordinates?corresponding?to?label?‘k‘
??boundary?=?B{k};
??%?compute?a?simple?estim
評(píng)論
共有 條評(píng)論