computer graphics

34
Computer Graphics Recitation 6

Upload: tarak

Post on 05-Jan-2016

20 views

Category:

Documents


0 download

DESCRIPTION

Computer Graphics. Recitation 6. Motivation – Image compression. What linear combination of 8x8 basis signals produces an 8x8 block in the image?. The plan today. Fourier Transform (FT). Discrete Cosine Transform (DCT). What is a transform?. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Computer Graphics

Computer Graphics

Recitation 6

Page 2: Computer Graphics

2

Motivation – Image compression

What linear combination of 8x8 basis signals produces an 8x8 block in the image?

Page 3: Computer Graphics

3

The plan today

Fourier Transform (FT). Discrete Cosine Transform (DCT).

Page 4: Computer Graphics

4

What is a transform?

Function: rule that tells how to obtain result y given some input x

Transform: rule that tells how to obtain a function G(f) from another function g(t) Reveal important properties of g More compact representation of g

Page 5: Computer Graphics

5

Periodic function

Definition: g(t) is periodic if there exists P such that g(t+P) = g(t)

Period of a function: smallest constant P that satisfies g(t+P) = g(t)

Page 6: Computer Graphics

6

Attributes of periodic function

Amplitude: max value of g(t) in any period Period: P Frequency: 1/P, cycles per second, Hz Phase: position of the function within a period

Page 7: Computer Graphics

7

Time and Frequency

example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t)

Page 8: Computer Graphics

8

Time and Frequency

example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t)

= +

Page 9: Computer Graphics

9

Time and Frequency

example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t)

= +

Page 10: Computer Graphics

10

Time and Frequency

example : g(t) = {1, a/2 < t < a/2 0, elsewhere

Page 11: Computer Graphics

11

Time and Frequency

example : g(t) = {

= +

=

1, a/2 < t < a/2 0, elsewhere

Page 12: Computer Graphics

12

Time and Frequency

example : g(t) = {

= +

=

1, a/2 < t < a/2 0, elsewhere

Page 13: Computer Graphics

13

Time and Frequency

example : g(t) = {

= +

=

1, a/2 < t < a/2 0, elsewhere

Page 14: Computer Graphics

14

Time and Frequency

example : g(t) = {

= +

=

1, a/2 < t < a/2 0, elsewhere

Page 15: Computer Graphics

15

Time and Frequency

example : g(t) = {

= +

=

1, a/2 < t < a/2 0, elsewhere

Page 16: Computer Graphics

16

Time and Frequency

example : g(t) = {

=

1, a/2 < t < a/2 0, elsewhere

1

1sin(2 )

k

A ktk

Page 17: Computer Graphics

17

Time and Frequency

If the shape of the function is far from regular wave its Fourier expansion will include infinite num of frequencies.

= 1

1sin(2 )

k

A ktk

Page 18: Computer Graphics

18

Frequency domain

Spectrum of freq. domain : range of freq. Bandwidth of freq. domain : width of the spectrum DC component (direct current): component of zero freq. AC – all others

Page 19: Computer Graphics

19

Fourier transform

Every periodic function can be represented as the sum of sine and cosine functions

Transform a function between a time and freq. domain

( ) ( )[cos(2 ) sin(2 )]

( ) ( )[cos(2 ) sin(2 )]

G f g t ft i ft dt

g t G f ft i ft df

Page 20: Computer Graphics

20

Fourier transform

Discrete Fourier Transform:1

0

1

0

1 2 2( ) ( )[cos( ) sin( )] 0 1

1 2 2( ) ( )[cos( ) sin( )] 0 1

n

t

n

t

ft ftG f g t i f n

n n n

ft ftg t G f i t n

n n n

0 n-1

Page 21: Computer Graphics

21

FT for digitized image

Each pixel Pxy = point in 3D (z coordinate is value of color/gray level

Each coefficient describes the 2D sinusoidal function needed to reconstruct the surface

In typical image neighboring pixels have “close” values surface is very smooth most FT coefficients small

Page 22: Computer Graphics

22

Sampling theory

Image = continuous signal of intensity function I(t)

Sampling: store a finite sequence in memory I(1)…I(n)

The bigger the sample, the better the quality? – not necessarily

Page 23: Computer Graphics

23

Sampling theory

We can sample an image and reconstruct it without loss of quality if we can :Transform I(t) function from to freq. DomainFind the max frequency fmax

Sample I(t) at rate > 2 fmax

Store the sampled values in a bitmap

2fmax is called Nyquist rate

Page 24: Computer Graphics

24

Sampling theory

Some loss of image quality because:fmax can be infinite.

choose a value such that freq. > fmax do not contribute much (low amplitudes)

Bitmap may be too small – not enough samples

Page 25: Computer Graphics

25

Fourier Transform

Periodic function can be represented as sum of sine waves that are integer multiple of fundamental (basis) frequencies

Frequency domain can be applied to a non periodic function if it is nonzero over a finite range

Page 26: Computer Graphics

26

Discrete Cosine Transform

A variant of discrete Fourier transformReal numbersFast implementationSeparable (row/column)

Page 27: Computer Graphics

27

Discrete Cosine Transform

Definition of 2D DCT: Input: Image I(i, j) 1 i N1, 1 j N2

Output: a new “image” B(u, v), each pixel stores the corresponding coefficient of the DCT

1 2

1 1 1 2

( , ) 4 ( , ) cos (2 1) cos (2 1)2 2

N N

i j

u vB u v I i j i j

N N

Page 28: Computer Graphics

28

Using DCT in JPEG

DCT on 8x8 blocks

Page 29: Computer Graphics

29

Using DCT in JPEG

DCT – basis

Page 30: Computer Graphics

30

Using DCT in JPEG

Block sizesmall block

faster correlation exists between neighboring pixels

large block better compression in smooth regions

Power of 2 – for fast implementation

Page 31: Computer Graphics

31

Using DCT in JPEG

For smooth, slowly changing images most coefficients of the DCT are zero

For images that oscillate – high frequency present – more coefficients will be non-zero

Page 32: Computer Graphics

32

Using DCT in JPEG

The first coefficient B(0,0) is the DC component, the average intensity

The top-left coeffs represent low frequencies, the bottom right – high frequencies

Page 33: Computer Graphics

33

Image compression using DCT

DCT enables image compression by concentrating most image information in the low frequencies

Loose unimportant image info (high frequencies) by cutting B(u,v) at bottom right

The decoder computes the inverse DCT – IDCT

Page 34: Computer Graphics

Bye-bye