Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8...

39
Computer Graphics Recitation 7
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    213
  • download

    0

Transcript of Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8...

Page 1: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

Computer Graphics

Recitation 7

Page 2: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

2

Motivation – Image compression

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

Page 3: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

3

The plan today

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

Page 4: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

4

What is a transformation?

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

Transformation : rule that tells how to obtain a function G(f) from another function g(t)

Page 5: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

5

What do we need transformations for?

Mathematical tool to solve problems Change a quantity to another form that might

exhibit useful features Example:

XCVI x XII 96 x 12 = 1152 MCLII

Page 6: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

6

Periodic function

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

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

Page 7: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

7

Attributes of periodic function

Amplitude: max value it has in any period Period: P Frequency: 1/P, cycles per second,Hz Phase: position of function within a period

Page 8: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

8

Time and Frequency

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

Page 9: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

9

Time and Frequency

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

= +

Page 10: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

10

Time and Frequency

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

= +

Page 11: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

11

Time and Frequency

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

Page 12: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

12

Time and Frequency

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

= +

=

Page 13: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

13

Time and Frequency

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

= +

=

Page 14: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

14

Time and Frequency

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

= +

=

Page 15: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

15

Time and Frequency

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

= +

=

Page 16: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

16

Time and Frequency

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

= +

=

Page 17: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

17

Time and Frequency

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

= A (1/k)sin(2kft)

Page 18: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

18

Time and Frequency

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

A (1/k)sin(2kft) =

Page 19: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

19

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 20: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

20

Fourier transform

G(f) = g(t)[cos(2ft) - i sin(2ft)]dt

g(t) = G(f)[cos(2ft) + i sin(2ft)]df

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

Transform a function between a time and freq. domain

Page 21: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

21

Fourier transform

Discrete

g(t) = (1/n) G(f)[cos(2ft/n) + i sin(2ft/n)] , 0<t<n-1

G(f) = (1/n) g(t)[cos(2ft/n) - i sin(2ft/n)] , 0<f<n-1

Page 22: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

22

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 almost flat most FT coefficients small

Page 23: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

23

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 24: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

24

Sampling theory

We can sample an image and reconstruct it without loss of quality if we can :

- Transform i(t) function from time to freq. Domain

- Find the max freq. fm

- Sample i(t) at rate > 2fm

- Store the sampled values in a bitmap

Page 25: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

25

Some loss of image quality because:

- fm can be infinite: choose a value s.t freq. > fm do not contribute much (low amplitudes)

- Bitmap may be too small

2fm is Nyquist rate

Sampling theory

Page 26: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

26

Fourier Transform

Periodic function can be represented as sum of sine waves that are integer multiple of

fundamental (basis) frequencies Freq. domain can be applied to a non periodic

function if it is nonzero over a finite range

Page 27: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

27

Discrete Cosine Transform

A variant of discrete Fourier transform - Real numbers - Fast implementation-Separable (row/column)

Page 28: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

28

Discrete Cosine Transform

Example: DCT on 8 points

G = (½) C P cos((2t+1)f/16) , C = { f f t

f=0 1 f=1…7

f

Fourier transform on 8 points

G = P cos(2ft/8) – i P sin(2ft/8) ,

f=0,1,…,7

f tt

Page 29: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

29

Discrete Cosine Transform

Example 8 points:

Same meaning: the 8 numbers Gf tell what sinusoidal func. should be combined to

approximate the function described by the 8 original numbers Pt

Page 30: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

30

Discrete Cosine Transform

G = (½) C P cos((2t+1)f/16) , C = { f f t

f=0 1 f=1…7

f

G3 = contribution of sinusoidal with freq. 3tp/16 to the 8 numbers Pt

G7 = contribution of sinusoidal with freq. 7tp/16 to the 8 numbers Pt

Example 8 points:

Page 31: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

31

The inverse DCT

P = (½) C G cos((2t+1)j/16) , t=0,1,…,7 j jt

Discrete Cosine Transform

Example 8 points:

Page 32: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

32

Discrete Cosine Transform

2D DCT

G = C C Pxy cos((2x+1)i/2n)cos((2y+1)j/2n)i jij

2D Inverse DCT (IDCT)

P =¼ C C Gij cos((2x+1)i/16) cos((2y+1)j/16)ixy j

f=0 1 f=1…7

C f = {

Page 33: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

33

Using DCT in JPEG

DCT on 8x8 blocks

Page 34: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

34

Using DCT in JPEG

Block size : small block

- faster - correlation exists between neighboring pixels

large block - better compression in “flat” regions

Power of 2 – for fast implementation

Page 35: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

35

Using DCT in JPEG

DCT – basis

Page 36: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

36

For almost flat surface most Gij=0

For surface that oscillates much many Gij non zero

G00 = DC coefficient

Numbers at top left of Gij contribution of low freq. sinusoidal to the surface, bottom right – high freq.

Using DCT in JPEG

Page 37: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

37

Numbers at top left of Gij contribution of low freq. sinusoidal to the surface, bottom right – high freq.

Scan each block in zig-zag order

Using DCT in JPEG

Page 38: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

38

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

• Loose unimportant image info buy cut Gij at right bottom

• Decoder computes the inverse IDCT

Image compression using DCT

Page 39: Computer Graphics Recitation 7. 2 Motivation – Image compression What linear combination of 8x8 basis signals produces an 8x8 block in the image?

See you next time