Docsity

Image Compression: Coding and Transform Techniques - Prof. B. S. Manjunath, Study notes of Electrical and Electronics Engineering

Partial preview of the text

Download Image Compression: Coding and Transform Techniques - Prof. B. S. Manjunath and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

Image Compression-II 1

IMAGE COMPRESSION-II

Week IX

IMAGE COMPRESSION

 Data redundancy

 Self-information and Entropy

 Error-free and lossy compression

 Huffman coding

 Predictive coding

 Transform coding

Image Compression-II 3

Data Redundancy

  • CODING : Fewer bits to represent frequent symbols.
  • INTERPIXEL / INTERFRAME : Neighboring pixels

have similar values.

  • PSYCHOVISUAL : Human visual system can not

simultaneously distinguish all colors.

L l r p r A avg k k

L

r k

=

"

0

1

Coding Redundancy (contd.)

 Consider equation (A): It makes sense to assign fewer bits to those r k for which p r (r k ) are large in order to reduce the sum.

 this achieves data compression and results in a variable length code.

 More probable gray levels will have fewer # of bits.

Image Compression-II 7

Decoder

symbol

decoder

Σ

Compressed

image e n

f n Predictor

f n

original

image

Prediction error:

e n = f n

  • f n

e n

is coded using a variable length code (symbol encoder)

f n = e n

  • f n
^
^
^

Example

Example 1: ˆ f n

=Int! i

f n " i i = 1

m

$

%

&

'

(

)

  • Linear predictor ; m = order of predictor

Example 2: ˆ f n

(x,y)=Int! i

f ( x , y " i )

i = 1

m

$

%

&

'

(

)

x

y

f(x,y)

In 2- D

X
W

xy

Past information

Current pixel f (x,y)

= Σ α (x’, y’) f (x’, y)

(x’, y’) ε W xy

Image Compression-II 9

Predictive coding and temporal redundancy

f

!

( x , y , t ) = round [ " f ( x , y , t # 1 )]

e ( x , y , t ) = f ( x , y , t ) # f

!

( x , y , t )

An example of first order predictor

Prediction error image

Histograms of original and error images.

ˆ (,)[(,1) fxyIntfxy =!

Image Compression-II 13

Predictive Coding With Feedback

f(x,y)

Q

symbol

encoder

P

e n e n

f n

.

f n

^

This feedback loop prevents

error building

**f n = e n

  • f n**

.

. (^) ^

.

Compressed

image

Compressed

image

Symbol

decoder

P

f n e n

f n

^

**f n = e n

  • f n**

.

. (^) ^

. . uncompressed

image

Example

f e f

e f

n n n

n n

!

1

f f

e

e

e

n n

n

n

n

!

1

and

Example:

0 < α < 1

prediction coefficient

Image Compression-II 15

Example

with feedback

f n

e n

= _ 1 2 1 2

e n

= _ 0 2 0 2

.

f n

.

f n

= _ 0 0 2 2
^

f(x,y)

Q
P

e n e n

f n

.

f n

^

Note: The quantizer used here is-- floor (e n

/2)*2. This is

different from the one used in the earlier example. Note

that this would result in a worse response if used without

Feedback (output will be flat at “ 0 ”).

.

Another example

{14, 15, 14, 15, 13, 15, 15, 14, 20, 26, 27, 28, 27, 27, 29, 37, 37, 62, 75, 77, 78, 79, 80, 81, 81, 82, 82}

Image Compression-II 19

Motion compensation in Video

Block Transform Coding

Section 8.2.

Image Compression-II 21

Transform coding

Construct

n X n

subimages

Forward

transform

Quantizer

Symbol

encoder N X N

images

Compressed

image

Compressed

image Symbol

decoder

Inverse

transform

Merge

n X n

subimages

Uncompressed

image

Blocking artifact: boundaries between subimages become

visible

Transform Selection

 DFT

 Discrete Cosine Transform (DCT)

 Wavelet transform

 Karhunen-Loeve Transform (KLT)

 ….

T ( u , v ) = g ( x , y ) r ( x , y , u , v )

y = 0

n! 1

x = 0

n! 1

g ( x , y ) = T ( u , v ) s ( x , y , u , v )!!! !8.2.

v = 0

N! 1

u = 0

N! 1

Image Compression-II 25

Discrete Cosine Transform

Ahmed, Natarajan, and Rao, IEEE T-Computers, pp. 90-93,

1-D Case: Extended 2N Point Sequence

Consider 1 - D first; Let x(n) be a N point sequence 0 n N - 1.

x(n)

2 - N point

y(n)

point

Y(u)

point

C(u)

!!

"

"

= + # # =

!! #

#!!

$

% &

DFT (^) N N

y n x n x N n

x n n N

x N n N n N

2

2 1

0 1

2 1 2 1

( ) ( ) ( )

( ),

( ),

x(n)

y(n)

Image Compression-II 27

DCT & DFT

Y ( u ) = y ( n )exp! j

2 "

2 N

un

$

%

&

'

( n = 0

2 N! 1

= x ( n )exp! j

2 "

2 N

un

$

%

&

'

( n = 0

N! 1

) +^ x (^2 N^!^1!^ n )exp^!^ j^

2 "

2 N

un

$

%

&

'

( n = N

2 N! 1

= x ( n )exp! j

2 "

2 N

un

$

%

&

'

( n = 0

N! 1

) +^ x ( m )exp^!^ j^

2 "

2 N

u ( 2 N! 1! m )

$

%

&

'

( m = 0

N! 1

= exp j

"

2 N

u

$

%

&

'

(

x ( n )exp! j

"

2 N

u! j

2 "

2 N

un

$

%

&

'

( n = 0

N! 1

  • exp j

"

2 N

u

$

%

&

'

(

x ( n )exp j

"

2 N

u + j

2 "

2 N

un

$

%

&

'

( n = 0

N! 1

= exp j

"

2 N

u

$

%

&

'

(

2 x ( n )cos

"

2 N

u ( 2 n + 1 )

$

%

&

'

( n = 0

N! 1

DCT

The N-point DCTof x(n), C(u), is given by

C ( u ) =

exp! j

"

2 N

u

$

%

&

'

( Y^ ( u ),^0 )^ u^ )^ N-^1

0 otherwise.

,

,

The unitary DCT transformations are:

F ( u ) = .( u ) f ( n )cos

"

2 N

( 2 n + 1 ) u

$

%

&

'

( ,

n = 0

N! 1

/ 0 )^ u^ )^ N^!^1 ,^ where

.( 0 ) =

1

N

, .( u ) =

2

N

for 1 ) k ) N! 1.

The inverse transformation is

f ( n ) = .( u ) F ( u )cos

"

2 N

( 2 n + 1 ) u

$

%

&

'

( ,

n = 0

N! 1

/ 0 )^ u^ )^ N^!^ 1.

Image Compression-II 31

DCT Basis functions

Implicit Periodicity-DFT vs DCT (Fig 8.32)

Image Compression-II 33

Why DCT?

 Blocking artifacts less pronounced in DCT than in DFT.

 Good approximation to the Karhunen-Loeve Transform (KLT) but

with basis vectors fixed.

 DCT is used in JPEG image compression standard.

Sub-image size selection (fig 8.26)

Image Compression-II 37

Zonal Coding

Zonal coding:

i th coefficient

in each sub

image

(1) Compute the variance of each

of the transform coeff; use the

subimages to compute this.

(2) Keep X% of their coeff. which

have maximum variance.

(3) Variable length coding

(proportional to variance)

Bit allocation: In general, let the number of bits allocated be made

proportional to the variance of the coefficients. Suppose the total

number of bits per block is B. Let the number of retained coefficients

be M. Let v(i) be variance of the i-th coefficient. Then

b ( i ) =

B M

1 2

log 2

v ( i )!

1 2 M

log 2

v ( i )

i = 1

M

Zonal Mask & bit allocation: an example

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

1 0 0 0 0 0 0 0

1 1 0 0 0 0 0 0

1 1 1 0 0 0 0 0

1 1 1 1 0 0 0 0

1 1 1 1 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

3 0 0 0 0 0 0 0

4 4 0 0 0 0 0 0

6 5 4 0 0 0 0 0

7 6 5 4 0 0 0 0

8 7 6 4 3 0 0 0

Image Compression-II 39

Typical Masks (Fig 8.36)

Image Approximations