Compression 2
Compression 2
• For example:-
• Your wife, Helen, will meet you at Logan Airport in Boston
at 5 minutes past 6:00 pm tomorrow night
compression
Compression Ratio:
Example:
(1) Coding
(2) Interpixel
(3) Psychovisual
• Lossy
– Not information preserving
– High compression ratios
• How close is to ?
• Criteria
– Subjective: based on human observers
– Objective: mathematically defined criteria
Encode message: a1 a2 a3 a3 a4
0 1
Encode
a1 a2 a3 a3 a4
[0.06752, 0.0688)
or,
0.068
Decode 0.572
a3
511 -
4/9/2020 Prof. K.P. Nayak 31
LZW Coding (cont’d)
As the encoder examines image pixels,
39 39 126 126 gray level sequences (i.e., blocks) that are
not in the dictionary are assigned to a
39 39 126 126 new entry.
39 39 126 126
39 39 126 126
Dictionary Location Entry
0 0 - Is 39 in the dictionary……..Yes
1 1 - What about 39-39………….No
. .
- Then add 39-39 in entry 256
255 255
256 -
39-39
511 -
CR = empty
If CS is found:
(1) No Output
(2) CR=CS
else:
(1) Output D(CR)
(2) Add CS to D
(3) CR=P
4/9/2020 Prof. K.P. Nayak 33
Decoding LZW
e.g., (0,1)(1,1)(0,1)(1,0)(0,2)(1,4)(0,2)
u , v = 0,1,......., N − 1
- The inverse discrete transform is defined as
f ( x, y ) = u =0 v =0 T (u , v)h( x, y, u , v)
N −1 N −1
x, y = 0,1,............, N − 1
4/9/2020 Prof. K.P. Nayak 39
Example : Discrete Fourier Transform
2 ( ux + vy )
j
g ( x, y , u , v ) = e N
ux +vy
2 ( )
1
h ( x, y , u , v ) = 2 e j N
4/9/2020 N
Prof. K.P. Nayak 40
Discrete cosine transform(DCT)
The discrete cosine transform (DCT) gets its name from the fact
that the rows of the N x N transform matrix C are obtained as a
function of cosines.
g ( x, y , u , v ) = h ( x, y , u , v )
(2 x + 1)u (2 y + 1)v
= (u ) (v) cos cos
2N 2N
Where
1
(u ) = for u = 0
N
2
= for u =1, 2 .........., N − 1
4/9/2020 N Prof. K.P. Nayak 41
Why DCT
16 11 10 16 24 40 51 61
12 12 14 19 26 58 60 55
14 13 16 24 40 57 69 56
qmat=
14 17 22 29 51 87 80 62
18 22 37 56 68 109 103 77
24 35 55 64 81 104 113 92
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
312/16
49 64 78 87 103 121 120 101
= 20
72 92 95 98 112 100 103 99
20 5 -3 1 3 -2 1 0
-3 -2 1 2 1 0 0 0
-1 -1 1 1 1 0 0 0
t=round(dcts. /qmat)= -1 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
20 5 -3 1 3 -2 1 0
-3 -2 1 2 1 0 0 0
-1 -1 1 1 1 0 0 0
t= round(dcts./qmat)= -1 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
[ 20,5,-3,-1,-2,-3,1,1,-1,-1,0,0,1,2,3,-2,1,1,0,0,0,0,0,0,1,1,0,1,0,EOB ]
4/9/2020 Prof. K.P. Nayak 52
Decoding the Coefficients
-36 -24 14 38 26 0 0 0
-14 -13 16 24 40 0 0 0
t X qmat= -14 0 0 29 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
58 25 15 30 65 40 -4 47
46 41 44 40 59 38 0 49
41 52 59 43 57 42 3 42
fs_hat=round(idct2(ds_hat))
44 54 58 40 58 47 3 33
49 52 53 40 61 47 1 33
53 50 53 46 63 41 0 45
55 50 56 53 64 34 -1 57
- SBC has been used extensively first in speech coding and later
in image coding.
256 X 256
128 X 128
Matlab toolbox
4/9/2020 Prof. K.P. Nayak 68
Comparison
Original(979 KB)