sopt_mltb_gradient_op - Compute gradient Compute the gradient of a two dimensional signal. Inputs: - I: Input two dimesional signal. - weights_dx: Weights in the x direction. - weights_dy: Weights in the y direction. Outputs: - dx: Gradient in x direction. - dy: Gradient in y direction.
0001 function [dx, dy] = sopt_mltb_gradient_op(I, weights_dx, weights_dy) 0002 % sopt_mltb_gradient_op - Compute gradient 0003 % 0004 % Compute the gradient of a two dimensional signal. 0005 % 0006 % Inputs: 0007 % 0008 % - I: Input two dimesional signal. 0009 % 0010 % - weights_dx: Weights in the x direction. 0011 % 0012 % - weights_dy: Weights in the y direction. 0013 % 0014 % Outputs: 0015 % 0016 % - dx: Gradient in x direction. 0017 % 0018 % - dy: Gradient in y direction. 0019 0020 dx = [I(2:end, :)-I(1:end-1, :) ; zeros(1, size(I, 2))]; 0021 dy = [I(:, 2:end)-I(:, 1:end-1) , zeros(size(I, 1), 1)]; 0022 0023 if nargin>1 0024 dx = dx .* weights_dx; 0025 dy = dy .* weights_dy; 0026 end 0027 0028 end