-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDCT8andZigzagScan.m
More file actions
28 lines (27 loc) · 898 Bytes
/
DCT8andZigzagScan.m
File metadata and controls
28 lines (27 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function out = DCT8andZigzagScan(in)
N = 8;
in = in - 128;
zigzag8_ind = [1,9,2,3,10,17,25,18,...
11,4,5,12,19,26,33,41,...
34,27,20,13,6,7,14,21,...
28,35,42,49,57,50,43,36,...
29,22,15,8,16,23,30,37,...
44,51,58,59,52,45,38,31,...
24,32,39,46,53,60,61,54,...
47,40,48,55,62,63,56,64]'; %generate by zigzag.m
%value fixed for enhanced efficiency
QTAB = [16,11,10,16,24,40,51,61;...
12,12,14,19,26,58,60,55;...
14,13,16,24,40,57,69,56;...
14,17,22,29,51,87,80,62;...
18,22,37,56,68,109,103,77;...
24,35,55,64,81,104,113,92;...
49,64,78,87,103,121,120,101;...
72,92,95,98,112,100,103,99]; %adapted from 'JpegCoeff.mat'
n = 0 : 1: N-1;
DCT = sqrt(2/N)*diag([sqrt(1/2), ones(1,N-1)])*cos(n'*(2*n + 1)*pi/(2*N));
in_DCT = DCT*in*DCT';
%in_DCT = dct2(in);
in_DCT = round(in_DCT./QTAB);
out = in_DCT(zigzag8_ind);
end