Roberts算子是一种利用局部差分算子寻找边缘的算子,由下式给出:
其中f(x,y)是具有整数像素坐标的输入图像,平方根运算使该处理类似于在人类视觉系统中发生的过程。
Roberts算子边缘定位准,但是对噪声敏感。适用于边缘明显而且噪声较少的图像分割,在应用中经常用Roberts算子来提取道路。
I=imread('lena.bmp');
I=im2double(I);
figure;
imshow(I);title('org img');
[height width R]=size(I);
for i=2:height-1
for j=2:width-1
R(i,j)=abs(I(i+1,j+1)-I(i,j))+abs(I(i+1,j)-I(i,j+1));
end
end
figure;
imshow(R,[]);
for i=1:height-1
for j=1:width-1
if (R(i,j)<0.25)
R(i,j)=1;
else R(i,j)=0;
end
end
end
figure;
imshow(R,[]);