0% found this document useful (0 votes)
9 views17 pages

CSE4227 Solns Chapter08

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views17 pages

CSE4227 Solns Chapter08

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Chapter 8: Image Compression

Origin42

1.b. .i. Solution: 024


Given image matrix,

3 4 7

3 4 7

3 4 7

For 8-bit image, codebook will be 9-bit,

Dictionary
Entry
Location

0 0
1 1
… …
255 255

256 -
… -
511 -

Using LZW encoding process,


Current Pixel Dictionary
Encoded Dictionary
Recognized Being Location
Output Entry
Sequence Processed (Codeword)

3 4 3 256 3-4

4 7 4 257 4-7

7 3 7 258 7-3

3 4 - - -

3-4 7 256 259 3-4-7

7 3 - - -

7-3 4 258 260 7-3-4

4 7 - - -

4-7 257

So, new codebook,

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

So, the output sequence is 3-4-7-256-258-257


1.b. .ii. Solution: 024
In my LZW coding process, it reduces spatial data redundancy. It assigns fixed-length code words
to variable length sequences of source symbols.

1.b. .iii. Solution: 024


Before compression,
Total matrix value 9
Each matrix value 8 bits
So, original image size = 9x8 =72 bits

After compression,
Total encoded output 6
Each encoded output 9 bits
So, compressed image size = 6x9 =54 bits

Compression ratio = 72/54 = 1.33 : 1


Yes, compression achieved.

5.a. . Solution: 024


(i)
Image compression is needed for:
● Data store at low storage
● Data transmission at minimum cost
(ii)
In image there are 3 types of data redundancies.
Coding redundancy: Most 2-D intensity arrays contain more bits than are needed to represent
the intensities.
Spatial and temporal redundancy: Pixels of most 2-D intensity arrays are correlated spatially
and video sequences are temporally correlated.
Irrelevant information: Most 2-D intensity arrays contain information that is ignored by the
human visual system.

(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.

5.b. Solution: 024


(i)
Given image matrix,

18 16 16

11 11 14

11 14 16

PDF,

Symbol Pixel Value Probability

a1 11 3/9 = 0.33

a2 14 2/9 = 0.22

a3 16 3/9 = 0.33

a4 18 1/9 = 0.11

Using Huffman coding process,


a1 11
0
a3 0
1 1
6 0 1
1
a2
1
4

a4
1
8

Symbol Pixel Value Codeword

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

As, H < Lavg. So, this compression is lossless.

(iv)
Compression ratio = 8/1.98 = 4.04 : 1
So, compression was achieved.
Enigma41

2.a. Solution:

2.b. Solution: 024


(i)
Given, image pixels,

f(x, y) f’(x, y)

1 4 3 3 6 5
=>
2 3 4 4 5 6

2 4 5 4 6 7

Total 9 pixel values. Each pixel value is increased by 2.


Row=M=3, Column=N=3

Erms = sqrt((1/9) x (2^2) x 9) = 2

(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

5.a. Solution: Rabab 039


(i) Image compression is needed for:
● Low data storage
● Data transmission at lower cost

(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

Symbol Pixel value Probability

a2 95 4/32 = 0.125

a3 169 4/32 = 0.125

a1 21 12/32 = 0.375

a4 243 12/32 = 0.375

Entropy = - [0.125log(0.125) + 0.125log(0.125) + 0.375log(0.375) + 0.375log(0.375) = 0.796 (Amar


1.81127 ashe ~ ID 077 log2 hobe)

(ii) Using Huffman Coding:

Symbol Pixel value Probability Huffman codeword

a2 95 4/32 = 0.125 0
a3 169 4/32 = 0.125 10

a1 21 12/32 = 0.375 110

a4 243 12/32 = 0.375 111

(iii) Lavg = (0.125x1) + (0.125x2) + (0.375x3) + (0.375x3) = 2.625


Compression ratio, C = (4x8x8) / (4x8x2.625) = 8 : 2.625 = 3.0476 : 1

(iv) RD = 1 - 1/C = 1 - 1/3.0476 = 0.671

(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.

The image is as follows:


39 40 60 80 100

39 40 60 80 100

39 40 60 80 100

39 40 60 80 100

39 40 60 80 100

Generating a 9-bit codebook:

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

80 100 80 259 80-100

100 39 100 260 100-39

39 40 - - -

39-40 60 256 261 39-40-60


60 80 - - -

60-80 100 258 262 60-80-100

100 39 - - -

100-39 40 260 263 100-39-40

40 60 - - -

40-60 80 257 264 40-60-80

80 100 - - -

80-100 39 259 265 80-100-39

39 40 - - -

39-40 60 - - -

39-40-60 80 261 266 39-40-60-80

80 100 - - -

80-100 39 - - -

80-100-39 40 265 267 80-100-39-40

40 60 - - -

40-60 80 - - -

40-60-80 100 264 268 40-60-80-100

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

Compression ratio = 200 : 117 = 1.709 : 1


So, compression is achieved.

COREi36
3.

Solution:
Solution:

Solution:

You might also like