% Elec 539 project 1
% Group RFC - Mara Prandi-Abrams, Anita Anderson, Oscar Pan
% 4/9/99

clear
close all

% ask user for image
in1 = input('Input image:\n','s');
im = freadbin(in1,256,256); 
in2 = input('Mask number (1:5)?\n','s');
masknum = str2num(in2);

% show the original image
imagesc(im)
title('Original image')
colormap(gray)

[Q, Qval]=blkproc2out(im, [8 8], 'process', masknum);


% we write the file here
fname=input('Destination File:\n','s');
writebits(Q, masknum, fname);

figure;
imagesc(Q);
title('Bit Values')
colormap(gray)

figure;
imagesc(Qval);
%Has NaNs
title('Quantized dct values')
colormap(gray)

y=find(Qval<2500);
m=min(min(Qval));
Qvalzeros=zeros(256)+m;
Qvalzeros(y)=Qval(y);
%Now NaNs equal the minimum value (will become zero)
figure;
imagesc(Qvalzeros);
colormap(gray)
title('Quantized dct values with NaNs as zeros');


