image compression
image compression
• 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:
Data Redundancy
Example:
Types of Data Redundancy
(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
Subjective Fidelity Criteria
Objective Fidelity Criteria
• Root mean square error (RMS)
Encode message: a1 a2 a3 a3 a4
0 1
Encode
a1 a2 a3 a3 a4
[0.06752, 0.0688)
or,
0.068
Example contd…
• The message a1 a2 a3 a3 a4 is encoded using
3 decimal digits or 3/5 = 0.6 decimal digits
per source symbol.
Decode 0.572
a3
511 -
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 -
Example
39 39 126 126 Concatenated Sequence: CS = CR + P
39 39 126 126
39 39 126 126 (CR) (P)
39 39 126 126
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
Decoding LZW
e.g., (0,1)(1,1)(0,1)(1,0)(0,2)(1,4)(0,2)
Transform based Coding
• Transform the image into a domain where
compression can be performed more
efficiently (i.e. reduce interpixel
redundancies).
• Transform types:- DFT, DCT, K-L Transform
~ (N/n)2 subimages
Transform selection
-Consider an image f (x,y) of size N X N
u , v 0,1,......., N 1
- The inverse discrete transform is defined as
x, y 0,1,............, N 1
Example : Discrete Fourier Transform
2 (uxvy )
j
g(x, y, u, v) e N
uxvy
2 ( )
1
h(x, y, u, v) 2 e j N
N
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)
(2x 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
Zig- Zag Scanning of the Coefficients
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 ]
Decoding the Coefficients
-36 -24 14 38 26 0 0 0
-14 -13 16 24 40 0 0 0
-14 0 0 29 0 0 0 0
t X qmat=
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
Computing the IDCT
67 12 -9 20 69 43 -8 42
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
Shifting Back the Coefficients
195 140 119 148 197 171 120 170
186 153 143 158 193 168 124 175
174 169 172 168 187 166 128 177
169 180 187 171 185 170 131 170
f_hat=fs_hat+128 172 182 186 168 186 175 131 161
177 180 181 168 189 175 129 161
181 178 181 174 191 169 128 173
183 178 184 181 192 162 127 185
- SBC has been used extensively first in speech coding and later
in image coding.
Wavelets as filter
256 X 256
128 X 128
Decomposition and Compression
Quantization
Two important observations:
Matlab toolbox
Comparison
Original(979 KB)