Académique Documents
Professionnel Documents
Culture Documents
Part 1
a-
Output:
b-
Output
Part b
Output
Part c
for M=1
100
200
300
400
500
600
700
800
900
200
300
400
500
600
700
800
900
1000
100 200 300 400 500 600 700 800 900 1000
for M=8
100
200
300
400
500
600
700
800
900
1000
100 200 300 400 500 600 700 800 900 1000
Part d
Code
x=double(imread('man.tiff'));
Block=block_dct2(x);
[m, n, nob]=size(Block);
s=n;
k=0;
noz=0; %number of zeros
nzn=0; %number of non zeros
for i=1:nob
quan(:,:,i)=Q.*round(Block(:,:,i)./Q); %quantized blocks
end
xq=iblock_dct2(quan);
b=x-xq; c=(norm(b,'fro')).^2; e=(norm(x,'fro')).^2;
disp('log10(||x-xq||^2/||x||=')
error=log10(c/e)
for i=1:(sqrt(nob*64)/s)
for j=1:(sqrt(nob*64)/s)
a((s*(i-1)+1:s*(i-1)+s),(s*(j-1)+1:s*(j-
1)+s))=Block(:,:,k+j); %dct coefficients matrix
qu((s*(i-1)+1:s*(i-1)+s),(s*(j-1)+1:s*(j-
1)+s))=quan(:,:,k+j); %quantized cofficients matrix
end
k=k+(sqrt(nob*64)/s);
end
disp('||a~ - a||');
A=norm((a-qu),'fro')
disp('||x~-x||');
B=norm(b,'fro')
%checking number of non-zero coefficients
[m,n]=size(qu);
for i=1:m
for j=1:m
if qu(i,j)==0
noz=noz+1;
else
nzn=nzn+1;
end
end
end
disp('number of non-zeros number');
a=nzn
imagesc(xq)
OUTPUT
quantized image
100
200
300
400
500
600
700
800
900
1000
100 200 300 400 500 600 700 800 900 1000