function C1 = BuildC1FromContinuity(Cont);
% function C1 = BuildC1FromContinuity(Cont);
%
% Cont is a matrix of size [m,n,o].  We will interpolate over the o direction, down to 4 directions,
% and take a local maximum in the m and n directions

C1 = ReduceToFourOri(Cont);
iBand = 1;
c1SpaceSS = [8:2:22];
pRange1 = ceil((c1SpaceSS(iBand)-1)/2);
pRange2 = floor((c1SpaceSS(iBand)-1)/2);
C1 = maxfilter(C1,[pRange1 pRange1 pRange2 pRange2]);
C1 = C1(4:4:end,4:4:end,:);
  
function out = ReduceToFourOri(in)
ninori = size(in,3);
sz = size(in);
in = reshape(in,[sz(1)*sz(2),ninori]);
a = zeros(ninori,4);
aidx = (1:ninori)/ninori;
uppart = 4 * aidx;
downpart = -4 * aidx + 2;
tri = max(0,min(uppart,downpart));
tri = (tri / sum(tri))';
a(:,1) = circshift(tri,floor(0  *ninori));
a(:,2) = circshift(tri,floor(.25*ninori));
a(:,3) = circshift(tri,floor(.5 *ninori));
a(:,4) = circshift(tri,floor(.75*ninori));
out = reshape(in*a,[sz(1),sz(2),4]);

