sopt_mltb_gradient_op_sphere - Compute gradient on sphere Compute the gradientof a signal on the sphere. The phi direction (x) is periodic, while the theta direction (y) is not. Inputs: - I: Input two dimesional signal on the sphere. - includeNorthPole: Flag indicating whether the North pole is included in the sampling grid (1 = North pole included, 0 = North pole not included). - weights_dx: Weights in the x (phi) direction. - weights_dy: Weights in the y (theta) direction. Outputs: - dx: Gradient in x (phi) direction. - dy: Gradient in y (theta) direction.
0001 function [dx, dy] = sopt_mltb_gradient_op_sphere(I, includeNorthpole, ... 0002 weights_dx, weights_dy) 0003 % sopt_mltb_gradient_op_sphere - Compute gradient on sphere 0004 % 0005 % Compute the gradientof a signal on the sphere. The phi direction (x) is 0006 % periodic, while the theta direction (y) is not. 0007 % 0008 % Inputs: 0009 % 0010 % - I: Input two dimesional signal on the sphere. 0011 % 0012 % - includeNorthPole: Flag indicating whether the North pole is included 0013 % in the sampling grid (1 = North pole included, 0 = North pole not 0014 % included). 0015 % 0016 % - weights_dx: Weights in the x (phi) direction. 0017 % 0018 % - weights_dy: Weights in the y (theta) direction. 0019 % 0020 % Outputs: 0021 % 0022 % - dx: Gradient in x (phi) direction. 0023 % 0024 % - dy: Gradient in y (theta) direction. 0025 0026 dx = zeros(size(I, 1),size(I, 2)); 0027 I_big = zeros(size(I, 1)+2,size(I, 2)); 0028 I_big(2:end-1, 1:end) = I; 0029 0030 % Theta direction 0031 if(includeNorthpole) 0032 dx = [I(2:end, :)-I(1:end-1, :) ; zeros(1, size(I, 2))]; 0033 dx(1,:) = zeros(); 0034 else 0035 dx = [I(2:end, :)-I(1:end-1, :) ; zeros(1, size(I, 2))]; 0036 end 0037 0038 % Phi direction 0039 if(includeNorthpole) 0040 dy = [I(:, 2:end)-I(:, 1:end-1) , I(:, 1)-I(:, end)]; 0041 else 0042 dy = [I(:, 2:end)-I(:, 1:end-1) , I(:, 1)-I(:, end)]; 0043 end 0044 0045 if nargin>2 0046 dx = dx .* weights_dx; 0047 dy = dy .* weights_dy; 0048 end 0049 0050 end