Roberts边缘检测算子





clear all;
sourcePic=imread('9.jpg'); %读取原图像
grayPic=rgb2gray(sourcePic); %转换成灰度图像
subplot(131);imshow(grayPic);title('原图');
[high,width]=size(grayPic);
newGrayPic=grayPic;%为保留图像的边缘一个像素
robertsNum=0; %经roberts算子计算得到的每个像素的值
robertThreshold=0.9; %设定阈值
for j=1:high-1 %进行边界提取
for k=1:width-1
robertsNum = abs(grayPic(j,k)-grayPic(j+1,k+1)) + abs(grayPic(j+1,k)-grayPic(j,k+1));
newGrayPic(j,k)=robertsNum;
end
end
subplot(132);imshow(newGrayPic);title('roberts算子的处理结果');
% Matlab自带函数边缘检测
% K为获取得到的关键帧的灰度图
BW3 = edge(grayPic,'roberts', 0.03);
subplot(133);imshow(BW3,[]);title('Matlab自带函数边缘检测');


转载 https://blog.csdn.net/baidu_21578557/article/details/51786249



clear all;
sourcePic=imread('9.jpg'); %读取原图像
grayPic=rgb2gray(sourcePic); %转换成灰度图像
subplot(131);imshow(grayPic);title('原图');
[high,width]=size(grayPic);
newGrayPic=grayPic;%为保留图像的边缘一个像素
robertsNum=0; %经roberts算子计算得到的每个像素的值
robertThreshold=0.9; %设定阈值
for j=1:high-1 %进行边界提取
for k=1:width-1
robertsNum = abs(grayPic(j,k)-grayPic(j+1,k+1)) + abs(grayPic(j+1,k)-grayPic(j,k+1));
newGrayPic(j,k)=robertsNum;
end
end
subplot(132);imshow(newGrayPic);title('roberts算子的处理结果');
% Matlab自带函数边缘检测
% K为获取得到的关键帧的灰度图
BW3 = edge(grayPic,'roberts', 0.03);
subplot(133);imshow(BW3,[]);title('Matlab自带函数边缘检测');


猜你喜欢

转载自blog.csdn.net/xiansong1005/article/details/80733299