CSE4227 Solns Chapter08
CSE4227 Solns Chapter08
Origin42
3 4 7
3 4 7
3 4 7
Dictionary
Entry
Location
0 0
1 1
… …
255 255
256 -
… -
511 -
3 4 3 256 3-4
4 7 4 257 4-7
7 3 7 258 7-3
3 4 - - -
7 3 - - -
4 7 - - -
4-7 257
Dictionary Dictionary
Location Entry
0 0
1 1
… …
255 255
256 3-4
257 4-7
258 7-3
259 3-4-7
260 7-3-4
After compression,
Total encoded output 6
Each encoded output 9 bits
So, compressed image size = 6x9 =54 bits
(iii)
Entropy = 5.3 bits/pixel, means minimum 5.3 bits required to represent a pixel without losing any
data.
Compression ratio = (512x512x8) / (512x512x5.3) = 1.509 : 1
This is the maximum compression that can be expected.
18 16 16
11 11 14
11 14 16
PDF,
a1 11 3/9 = 0.33
a2 14 2/9 = 0.22
a3 16 3/9 = 0.33
a4 18 1/9 = 0.11
a4
1
8
a1 11 0
a3 16 10
a2 14 110
a4 18 111
(ii)
Original image entropy, H = -[(0.33)x log2(0.33) + (0.22)x log2(0.22) + (0.33)x log2(0.33) + (0.11)x
log2(0.11)] = 1.7578 bits/pixel
(iii)
Huffman coding is a Coding Redundancy reduce technique.
Average bit requirement per symbol, Lavg = 0.33x1 + 0.22x3 + 0.33x2 + 0.11x3 = 1.98 bits/pixel
(iv)
Compression ratio = 8/1.98 = 4.04 : 1
So, compression was achieved.
Enigma41
2.a. Solution:
f(x, y) f’(x, y)
1 4 3 3 6 5
=>
2 3 4 4 5 6
2 4 5 4 6 7
(ii)
Gm(n) = G4(9)
m =4
n =9
Step 1:
floor(n/m) = floor(9/4) = 2
So, unary value followed by 0 = 110
Step 2:
k = ceiling(log2(m)) =ceiling(log2(4)) = 2
c =2^k - m = 2^2 - 4 = 0
r = n mod m = 9 mod 4 = 1
r’ = 01 ; [r+c truncated to k bits as 0<=r<c is not accomplished]
Step 3:
Golomb code for G4(9) = “ unary value followed by 0 ” + “ r’ ” = 11001
Recursive40
(ii) There are 3 types of data redundancies: Coding, spatial, irrelevant information
(iii) Arithmetic Coding is a lossless compression technique that encodes data by creating a code string
which represents a fractional value on the number line between 0 and 1
(iv)
(v)
5.b. Solution:
Prototype39
1.
Solution:
Solution:
Return38
5.
Solution:
Solution: Rabab 039
(i) Total pixels in image = 4*8 = 32
a2 95 4/32 = 0.125
a1 21 12/32 = 0.375
a2 95 4/32 = 0.125 0
a3 169 4/32 = 0.125 10
(v)
Solution:
Given in Origin42, 1(b)
Malware37
1.
Solution:
A grayscale image with most of the pixel values being the same is a spatial redundancy. This can be
overcome by many compression techniques involving spatial redundancy, most notably LZW coding.
39 40 60 80 100
39 40 60 80 100
39 40 60 80 100
39 40 60 80 100
Location Entry
0 0
… …
255 255
256 -
… …
511 -
Using LZW:
Current Dictionary
Pixel being Encoded Dictionary
Recognized Location
processed output entry
sequence (codeword)
39
39 40 39 256 39-40
40 60 40 257 40-60
60 80 60 258 60-80
39 40 - - -
100 39 - - -
40 60 - - -
80 100 - - -
39 40 - - -
39-40 60 - - -
80 100 - - -
80-100 39 - - -
40 60 - - -
40-60 80 - - -
Location Entry
0 0
… …
255 255
256 39-40
257 40-60
258 60-80
259 80-100
260 100-39
261 39-40-60
262 60-80-100
263 100-39-40
264 40-60-80
265 80-100-30
266 39-40-60-80
267 80-100-39-40
268 40-60-80-100
269 -
… …
511 -
Before compression,
Total outputs = 25
Bit size = 8
So, image size = 25*8 = 200
After compression,
Total outputs = 13
Bit size = 9
So, image size = 13*9 = 117
COREi36
3.
Solution:
Solution:
Solution: