📄 myedge_laplacian.m
字号:
function pedge_laplacian=myedge_laplacian(pmat)
%Laplacian算子检测图像边缘
[row col]=size(pmat); %原始图像的大小
%对图像进行零填充
pfilled=zeros(row+2,col+2);
pfilled(2:row+1,2:col+1)=pmat;
%定义模板
H=[-1 -1 -1;-1 8 -1;-1 -1 -1];
%计算各点的灰度值
pedge_laplacian=zeros(row,col);
for i=1:row
for j=1:col
array=[pfilled(i,j) pfilled(i,j+1) pfilled(i,j+2);pfilled(i+1,j) pfilled(i+1,j+1) pfilled(i+1,j+2);pfilled(i+2,j) pfilled(i+2,j+2) pfilled(i+2,j+2)];
pedge_laplacian(i,j)=sum(sum(H.*array));
end
end
%转换为图像格式
pedge_laplacian=uint8(pedge_laplacian);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -