%
%  macm 202 -- 11 jan 03 -- djm
%
%  w2ifft.m:  matlab monocolor [0,1] data from complex fourier data

figure(3);  clf;  figure(4);  clf

%  fourier masking (mask matrices are matrices of 0/1's only)

maskno = 1;
switch maskno
    case{1}
        masklo = (km.^2 + lm.^2)>=(0^2);
        maskhi = (km.^2 + lm.^2)<(20^2);
        mask   = masklo .* maskhi;
    case{2}
        mask   = (log(abs(imfour))>3);
end

%  count number of nonzero fourier modes.

keep = sum(mask(:));
disp(['number of nonzero fourier modes = ' num2str(keep)])
disp(['percent information = ' num2str(100*keep/imsize(1)/imsize(2))])

%  this line reconstitutes a partial image

impart = ifft2(ifftshift(mask.*imfour));

%  partial image

figure(4);  clf
imagesc(k,l,real(impart));
%colormap(copper);  caxis([0 1]);  colorbar
colormap(copper);  colorbar
title(['\bf partial image for ' file])
xlabel(['\bf # of pixels = ' num2str(imsize(2))])
ylabel(['\bf # of pixels = ' num2str(imsize(1))])
axis equal;  axis image

%  fourier coefficients plot

figure(3);  clf

immin = min(imfabs(:));
imagesc(k,l,log(imfabs));  
colormap(flipud(hot));  colorbar;  cx = caxis;

imagesc(k,l,log(mask.*imfabs + (1-mask)*immin));  
caxis(cx);  colorbar;
title(['\bf fourier coefficents for masked ' file ' (magnitude)'])
xlabel(['\bf masked k-axis'])
ylabel(['\bf masked l-axis'])
axis equal;  axis image


