以二值圖像circles.png(黑色背景白色前景)為例,根據掏空内部點算法,運用Matlab程式設計實作二值圖像的輪廓提取。
I=imread('circles.png');
[M,N]=size(I);
buffer=I;
for i=:M-
for j=:N-
if(I(i,j)==&I(i-,j)==&I(i+,j)==&I(i,j-)==&I(i,j+)==&I(i-,j-)==&I(i-,j+)==&I(i+,j-)==&I(i+,j+)==)%÷‹Œß8∏ˆµ„æ˘Œ™∞◊…´
buffer(i,j)=;
end
end
end
subplot(,,);
imshow(I);
subplot(,,);
imshow(buffer);