function
BinOut(A,M,imnum)
% This function will quantize the image matrix A,
using the bit mask M
n = length(A);
switch imnum
case
1
imfile = 'baby.bin';
case
2
imfile = 'building.bin';
case
3
imfile = 'kgirl.bin';
otherwise
disp('Unknown image file');
end
fid
= fopen(imfile,'wb');
for i = 1:n
for j = 1:n
if M(i,j)
~= 0
wtype = strcat('bit', int2str(M(i,j)+1));
fwrite(fid, A(i,j), wtype);
end
end
end
fclose(fid);
%fid =
fopen(imfile,'rb');
%for i = 1:n
%
for j = 1:n
% if M(i,j)
~= 0
% wtype =
strcat('ubit', int2str(M(i,j)));
%
B(i,j) = fread(fid, 1, wtype);
% else
%
B(i,j) = 0;
% end
% end
%end
%fclose(fid);