资源简介
此资源为一个压缩包,内包含Prewitt、Sobel、Roberts三种边缘检测算法,检测效果各不相同,注释不是特别多,适合有一定基础的使用,也适合直接拿过来用结果的使用。数字图像处理课程资源。
代码片段和文件信息
clcclearclose all;
img = imread(‘sjtu.jpg‘);%读取原图像
gray = rgb2gray(img);
grayPic = mat2gray(gray);
[mn] = size(grayPic);
newGrayPic = grayPic;
PrewittNum=0;%经Prewitt算子计算得到的每个像素的值
hold = [0.2 0.5 0.8];
sort = 2;
subplot(221)imshow(gray);
title(‘oringinal‘);
name = {‘ ‘‘0.2‘‘0.5‘‘0.8‘}
for PrewittThreshold = hold;
for j=2:m-1 %进行边界提取
for k=2:n-1
PrewittNum=abs(grayPic(j-1k+1)-grayPic(j+1k+1)+grayPic(j-1k)-grayPic(j+1k)+grayPic(j-1k-1)-grayPic(j+1k-1))+abs(grayPic(j-1k+1)+grayPic(jk+1)+grayPic(j+1k+1)-grayPic(j-1k-1)-grayPic(jk-1)-grayPic(j+1k-1));
if(PrewittNum > PrewittThreshold)
newGrayPic(jk)=255;
else
newGrayPic(jk)=0;
end
end
end
subplot(22sort);imshow(newGrayPic);
title(name{sort});
sort = sort+1;
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 854 2018-04-10 12:00 Exp3_Prewitt.m
文件 721 2018-04-10 12:01 Exp3_Roberts.m
文件 886 2018-04-10 12:01 Exp3_Sobel.m
评论
共有 条评论