laplacian.m

来自「3D shape reconstruction matlab code. It 」· M 代码 · 共 59 行

M
59
字号
function L = laplacian(A,dir)% Compute the laplacian of A using either the forward% difference scheme or the backward difference scheme%% Copyright 2006 Paolo Favaro (p.favaro@hw.ac.uk)% % School of Engineering and Physical Sciences% Heriot-Watt University, Edinburgh, UK% % Last revision: May 2006%% This program can be used only for research purposes.% This program is distributed WITHOUT ANY WARRANTY; % without even the implied warranty of MERCHANTABILITY % or FITNESS FOR A PARTICULAR PURPOSE.% padding sizewin = 3;if (size(A,3) >  1)       | ...   (size(A,2) == 1)       | ...   (size(A,1) == 1)       | ...   (size(A,1) <  2*win+1) | ...   (size(A,2) <  2*win+1)       error('function:laplacian:wrongInput',...         ['Function laplacian can only handle matrices\n'...          'and they must be at least %ix%i.'],2*win+1,2*win+1);endA = squeeze(A);[M,N] = size(A);% compute the regularization termsx = zeros(M,N);sy = zeros(M,N);sxx = zeros(M,N);syy = zeros(M,N);% alternate the finite difference methodif strcmp(dir,'forward')    sx(:,2:N) = diff(A,1,2);    %sx(:,1) = sx(:,2);    sy(2:M,:) = diff(A,1,1);    %sy(1,:) = sy(2,:);    sxx(:,1:N-1) = diff(sx,1,2);    sxx(:,N) = sxx(:,N-1);    syy(1:M-1,:) = diff(sy,1,1);    syy(M,:) = syy(M-1,:);else    sx(:,1:N-1) = diff(A,1,2);    %sx(:,N) = sx(:,N-1);    sy(1:M-1,:) = diff(A,1,1);    %sy(M,:) = sy(M-1,:);    sxx(:,2:N) = diff(sx,1,2);    sxx(:,1) = sxx(:,2);    syy(2:M,:) = diff(sy,1,1);    syy(1,:) = syy(2,:);endL = sxx+syy;return

⌨️ 快捷键说明

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