⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comp_laplacian.m

📁 this is a very very very nice code
💻 M
字号:
%Function computes the laplacian of an image, but only on pixels defined by
%the input parameter mask. Wind is the sub-window over which to compute (to
%save time by not checking regions the user knows contain no true parts of
%the mask), and type defines the type of laplacian to perform
function out = comp_laplacian_test(in, pix_set, type)

out = zeros(size(in));
if type == 1
    %Compute the standard laplacian
    for k = 1:size(pix_set,1)
        y = pix_set(k,1);
        x = pix_set(k,2);
        out(y,x) = -4*in(y,x) + in(y+1,x) + in(y-1,x) + in(y,x+1) + in(y,x-1);
    end

elseif type == 2
    %Compute the 1D (in the y-direction) laplacian
    for k = 1:size(pix_set,1)
        y = pix_set(k,1);
        x = pix_set(k,2);
        out(y,x) = in(y+1,x) + in(y-1,x) -2*in(y,x);
    end
        
elseif type == 3
    %Compute the 1D (in the x-direction) laplacian
    for k = 1:size(pix_set,1)
        y = pix_set(k,1);
        x = pix_set(k,2);
        out(y,x) = in(y,x+1) + in(y,x-1) -2*in(y,x);
    end

elseif type == 4
    %Compute the "cross-laplacian" used in the anisotropic diffusion
    for k = 1:size(pix_set,1)
        y = pix_set(k,1);
        x = pix_set(k,2);
        out(y,x) = ( -in(y+1,x+1) - in(y-1,x-1) + in(y+1,x-1) + in(y-1,x+1) ) / 4;
    end
    
elseif type == 5
    %Compute the "cross-laplacian" used in the anisotropic diffusion
    for k = 1:size(pix_set,1)
        y = pix_set(k,1);
        x = pix_set(k,2);
        out(y,x) = sum(sum(in(y-1:y+1, x-1:x+1))) - 9*in(y,x);
    end
    
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -