Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
%
% Script file: fftBox.m
% Fourier Spectrum Plot of Box function
%
X1=linspace(0,1,17);
Y1=ones(1,length(X1));
X2=linspace(1,16,241);
Y2=zeros(1,length(X2));
X=[X1 X2]; Y=[Y1 Y2];
W=abs(fftshift(fft(Y)));
subplot(2,1,1)
plot(X,Y,'r'); axis([0 16, 0,1.2]); title('Box function')
subplot(2,1,2)
plot(W,'b-');
title('Fourier Spectrum of Box function')
Q=xlsread('Qtable.xls','A2:H9');
fin=fopen('block8x8.txt','r');
fout=fopen('dctO.txt','w');
fgetl(fin); X=fscanf(fin,'%f',[8,8]); fclose(fin); X=X';
Y=dct2(X-128,[8,8]);
fprintf(fout,'DCT coefficients\n');
for i=1:8
for j=1:8 fprintf(fout,'%6.1f',Y(i,j)); end; fprintf(fout,'\n');
end
Y=Y./Q; % Y=fix(Y+0.5*(Y>0));
for i=1:8
for j=1:8
if (Y(i,j)>0) Y(i,j)=fix(Y(i,j)+0.5); else Y(i,j)=fix(Y(i,j)-0.5); end
end
end
fprintf(fout,'Quantized DCT coefficients\n');
for i=1:8
for j=1:8 fprintf(fout,'%4d',Y(i,j)); end; fprintf(fout,'\n');
end
fclose(fout);
write to file
huffman encoding
shift 128
DCT
run-length encoding
round
run-length encoding
:
-26,-3,0,,-1,-1,0,0,0,0.
JPEG Decoding
image result
shift 128
IDCT
huffman decoding
run-length decoding
CameraMan
()
49.3 KB
468 KB
257 KB
188 KB
-----------------
-----------------
-----------------
-----------------
zip
-----------------
42.5KB
(82.61%)
111KB
(23.72%)
219KB
(85.21%)
137KB
(72.87%)
rar
-----------------
36.6KB
(74.24%)
97.3KB
(20.79%)
164KB
(63.81%)
116KB
(61.7%)
jpg
-----------------
12.9KB
(26.17%)
26.5KB
(5.662%)
62.0KB
(24.12%)
46.6KB
(24.79)
project
-----------------
11.2KB
(22.75%)
9.48KB
(2.024%)
28.1KB
(10.95%)
24.3KB
(12.93%)
Plusplus
lena
boats
500
468
450
400
350
257
300
250
200
150
100
50
0
9.48
49.3
11.2
42.5
36.6
12.9
CameraMan
28.1
219
188
164
111
97.3
26.5
24.3
137
116
62
Plusplus
lena
Original
Project
zip
rar
jpg
46.6
boats