資源簡介
使用matlab識別出圖像中的圓形,計算并標注出原形坐標和圓的位置
代碼片段和文件信息
%識別圖像中的圓,并畫出來。
function[xy]?=step2(ImageFile)
%?Step?1:?讀入彩色圖像
RGB?=?imread(‘08.jpg‘);
figure
imshow(RGB)
title(‘Original?Image‘);
%?Step?2:?轉化為灰度圖像?
GRAY?=?rgb2gray(RGB);
figure
imshow(GRAY)
title(‘Gray?Image‘);
%?Step?3:?圖像二值化,以便為邊界跟蹤做準備
threshold?=?graythresh(GRAY);
BW?=?im2bw(GRAY?threshold);
figure
imshow(BW)
title(‘Binary?Image‘);
%?Step?4:?二值圖像反色
BW?=?~?BW;
figure
imshow(BW)
title(‘Inverted?Binary?Image‘);
%?Step?5:?尋找圖像的外邊界,參數值選用noholes可避免搜索內部輪廓以加速處理過程
[BL]?=?bwboundaries(BW?‘noholes‘);
%?Step?6:?決定對象屬性
STATS?=?regionprops(L?‘all‘);?%?we?need?‘BoundingBox‘?and?‘Extent‘
%?Step?7:?判斷形狀
%?Squ
- 上一篇:車牌字符分割垂直投影切分matlab程序
- 下一篇:matlab實現水平集方法
評論
共有 條評論