Docsity

Discrete Cosine Transform - Lecture Notes | ECE 161C, Study notes of Digital Signal Processing

Toggle sidebar
bg1
Discrete Cosine Transform
Discrete
Cosine
Transform
Nuno Vasconcelos
UCSD
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20

Partial preview of the text

Download Discrete Cosine Transform - Lecture Notes | ECE 161C and more Study notes Digital Signal Processing in PDF only on Docsity!

Discrete Cosine TransformDiscrete

Cosine Transform

Nuno Vasconcelos

UCSD

Discrete Fourier Transform•

last classes, we have studied the DFT

due to its computational efficiency the DFT is verypopular

however, it has strong disadvantages for someapplicationsapplications

  • it is complex– it has poor energy compaction

energy compaction

  • is the ability to pack the energy of the spatial sequence into as

few frequency coefficients as possible

q

y

p

  • this is very important for image compression– we represent the signal in the frequency domain

if compaction is high we only have to transmit a few coefficients

  • if compaction is high, we only have to transmit a few coefficients– instead of the whole set of pixels

Image compression•

an image compression system has three main blocks

  • a transform (usually DCT on 8x8 blocks)– a quantizer

(

)

  • a lossless (entropy) coder

each tries to throw away information which is notessential to understand the image, but costs bits

g ,

Image compression•

the transform throws away correlations

  • if you make a plot of the value of a pixel as a function of one of

its neighborsits neighbors

  • you will see that the pixels are highly correlated (i.e. most of the

time they are very similar)

  • this is just a consequence of the fact that surfaces are smooth

j

q

Image compression•

the transform eliminates these correlations

  • note that if x[0] similar to x[1], the

[

]

[ ]

0 ] 1 [ ] 0 [ 1

] 0 [ 2 ] 1

[

]

[

x

x

X

x

x

x

X

  • in the transform domain we only have to transmit one number

without any significant cost in image qualityby “decorrelating” the signal we reduced the bit rate to ½!

  • by

decorrelating” the signal we reduced the bit rate to ½!

  • note that an orthogonal matrix

I

T

T

T

applies a rotation to the pixel space

  • this aligns the data with the canonical axes

Image compression•

a second advantage of working in thefrequency domain

  • is that our visual system is less sensitive

to distortion around edges

  • the transition associated with the edge

masks our ability to perceive the noise

  • e.g. if you blow up a compressed picture,

it is likely to look like this

  • in general, the

compressionerrors are more annoying in thesmooth imageregions

Image compression•

important point: by itself, the transform

  • does not save any bits– does not introduce any distortion

both of these happen when we throw away information

this is called “lossy compression” and implemented by

this is called

lossy compression

and implemented by

the quantizer

what is a quantizer?

  • think of the round() function, that rounds to the nearest integer– round(1) = 1; round(0.55543) = 1; round (0.0000005) = 0– instead of an infinite range between 0 and 1 (infinite number of

instead of an infinite range between 0 and 1 (infinite number ofbits to transmit)

  • the output is zero or one (1 bit)

we threw away all the stuff in between but saved a lot of bits

  • we threw away all the stuff in between, but saved a lot of bits– a quantizer does this less drastically

Quantizer •

it is a function of this type

  • inputs in a given range are mapped

to the same o tp tto the same output

to implement this, we

    1. define a quantizer step size Q

)

q

p

    1. apply a rounding function

x

round

x

the larger the Q, the less reconstruction levels we have

Q

round

x

q

g

  • more compression at the cost of larger distortion– e.g. for x in [0,255], we need 8 bits and have 256 color values– with Q = 64 we only have 4 levels and only need 2 bits
    • with Q = 64, we only have 4 levels and only need 2 bits

Quantizer•

next we apply a transform (e.g. 8x8 DCT)

DCT

Quantizer•

and quantize with a varying Q

DCT

Q mtx

Quantizer•

this saves a lot of bits, but we no longer have an exactreplica of original image block

DCT

quantized DCT

DCT

quantized

DCT

inverse DCT

original pixels

Quantizer•

note, however, that visually the blocks are not verydifferent

i

i

l

d

d

original

decompressed

f

“

”

we have saved lots of bits without much “perceptual” loss

  • this is the reason why JPEG and MPEG work

Discrete Cosine Transform •

note that

  • the better the energy compaction – the larger the number of coefficients

that get wiped out

  • the greater the bit savings for the same

loss

this is why the DCT isimportantimportant

we will do mostlythe 1D-DCT

  • the formulas are simpler

the insights the same

  • as always, extension to

2D is trivial

Discrete Cosine Transform•

the first thing to note is that there are various versions ofthe DCT

  • these are usually known as DCT-I to DCT-IV– they vary in minor details– the most popular is the DCT-II,

0

1

⎧⎪

k

also known as even symmetricDCT, or as “the DCT”

− N

1

[ ]

,

1

, 1

0

, 2 1

⎧⎪⎨ ⎪⎩

<

≤

=

=

N

k k

k

w

[ ]

[ ]

∑

− =

otherwise

N k n k N n x k C

N n

x

cos

(^10)

π

[ ]

[ ]

∑

− =

N n n k N k C k w N n x

N k

x

cos

]

[

(^10)

π

otherwise