% derivatives.m Steve Mann, 1992
%
% computes derivatives of 2 pictures, based on first differences
% If E was 480 by 512, normally El (time) would be 480 by 512 (same size as E)
% Em (down) would be 479 by 512
% En (right) would be 480 by 511
% but all are cropped (delete last row or col, as required)
% to 479 by 511 so that they are the SAME SIZE
%
% Use: [El,Em,En] = derivatives(E1,E2);
function [El,Em,En] = derivatives_based_on_first_differences(E1,E2);
[M,N] = size(E1);
[M2,N2] = size(E2);
if ((M2 ~= M) | (N2 ~= N))
s=sprintf('derivatives.m: *** %g by %g NOT SAME SIZE as %g by %g. ***', ...
M,N,M2,N2)
end%if
El = E2(1:M-1,1:N-1) - E1(1:M-1,1:N-1); % time derivative
Em = (diff(E1(:,1:N-1)) + diff(E2(:,1:N-1)))/2; % down direction deriv
En = (diff(E1(1:M-1,:).').' + diff(E2(1:M-1,:).').')/2; % across direction der