Laplacian算子图像提升

来源:互联网 发布:淘宝网店进销存 编辑:程序博客网 时间:2024/04/28 16:25
%Laplacian微分算子提升图像,中心系数为负原来算子为[0,1,0;1,-4,1;0,1,0];f(x,y)-[Laplacian算子]
function d=Laplacian_strength(x,n)
d=x;
operator=[0,-1,0;-1,5,-1;0,-1,0];
[width,height]=size(x);
for ii=1:width-(n-1)
    for jj=1:height-(n-1)
    tmp=x(ii:ii+n-1,jj:jj+n-1).*operator;
    p=sum(sum(tmp));
    d(ii+(n-1)/2,jj+(n-1)/2)=p;
    end

end

%==================================================================================
%author:王同乐
%date:2016/10/30
img=imread('lena.png');
img=rgb2gray(img);
img=im2double(img);%输入图像类型为uint8,将其转换为double类型进行运算
%====================================Lalapcian提升
subplot(1,2,1);imshow(img);title('原图');
subplot(1,2,2);imshow(Laplacian_strength(img,3));title('laplacian提升后的图像');


效果图:


0 0