% show high pass and low pass filter pairs and their actions on smooth images.

% get image 
T = (0:256)/256;
%X = 127*(1+cos(2*pi*(T'-0.5))*cos(2*pi*(T-0.5)));
X = 256*(cos(pi*(T'-0.5))*cos(pi*(T-0.5)));

map = gray(256);


% define low and high pass masks
lo = [1 1];  lo = lo/sum(lo);
hi = [1,-1]; hi = hi/sum(abs(hi));
Xll = circconv2(X,lo'*lo);
Xhl = circconv2(X,hi'*lo);
Xlh = circconv2(X,lo'*hi);
Xhh = circconv2(X,hi'*hi);


figure(1);
imshow(X,map);
title('original')

figure(2);
subplot(2,2,1)
imshow(Xll,map);
title('low-low - absolute intensity')
subplot(2,2,2)
imshow(abs(Xlh),map);
title('low-high - absolute intensity')
subplot(2,2,3)
imshow(abs(Xhl),map);
title('high-low - absolute intensity')
subplot(2,2,4)
imshow(abs(Xhh),map);
title('high-high - absolute intensity')

Ell = energy(Xll);
Elh = energy(Xlh);
Ehl = energy(Xhl);
Ehh = energy(Xhh);
E = energy(X);

Elist = 100*[Ell/E,Elh/E,Ehl/E,Ehh/E]

figure(3);
subplot(2,2,1)
imshow(Xll,[]);
title('low-low - relative intensity')
subplot(2,2,2)
imshow(abs(Xlh),[]);
title('low-high - relative intensity')
subplot(2,2,3)
imshow(abs(Xhl),[]);
title('high-low - relative intensity')
subplot(2,2,4)
imshow(abs(Xhh),[]);
title('high-high - relative intensity')


figure(4)
mesh(X)
