%
% out = trans(in)
%
% in = input image (after being read in with freadbin)
% out = [sums diffs]
%
% This programs takes in an image (in) and outputs the normalized
% sums of adjacent row elements, then differences between adjacent
% row elements.
%
% Developed by  Andy Doran
%               Rice University
% 		April, 1999
%

function out = trans(in)

% Get size of input image
[x y] = size(in);
pix = x*y;

% Put 'in' into an pix/2 by 2 matrix, counting off by rows.
in_tpose = in';
in_vect = in_tpose(:);
new = reshape(in_vect,2,pix/2);
new_tpose = new';

% Get column vector of sums and differences
sums = new_tpose*[1 1]'/sqrt(2);
diffs = new_tpose*[1 -1]'/sqrt(2);

% Put column vectors into x by x/2 matrices
nsums = reshape(sums,x/2,x);
nsums_t = nsums';
ndiffs = reshape(diffs,x/2,x);
ndiffs_t = ndiffs';

% Create new out matrix of sums and differences.
out = [nsums_t ndiffs_t];
