function [g tE] = trfd(g)
% Compute "time"-reversed horizontal and vertical finite differences on the 
% current estimate x 
%
% Use periodic boundaries

%% Application of "time"-reversed horizontal finite difference
h = g(:, :, 1);
trh = [h(:,end) h];
trh = imfilter(trh, [1 -1], 'circular');
trh = trh(:, 1:end-1);

%% Application of "time"-reversed vertical finite difference
v = g(:, :, 2);
trv = [v(end,:); v];
trv = imfilter(trv, [1 -1]', 'circular');
trv = trv(1:end-1, :);

g = trh + trv;
