Computer Graphics Recitation 6 Motivation Image compression What

  • Slides: 33
Download presentation
Computer Graphics Recitation 6

Computer Graphics Recitation 6

Motivation – Image compression What linear combination of 8 x 8 basis signals produces

Motivation – Image compression What linear combination of 8 x 8 basis signals produces an 8 x 8 block in the image? 2

The plan today n n Fourier Transform (FT). Discrete Cosine Transform (DCT). 3

The plan today n n Fourier Transform (FT). Discrete Cosine Transform (DCT). 3

What is a transform? n n Function: rule that tells how to obtain result

What is a transform? n n 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 4

Periodic function n n Definition: g(t) is periodic if there exists P such that

Periodic function n n 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) 5

Attributes of periodic function n n Amplitude: max value of g(t) in any period

Attributes of periodic function n n 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 6

Time and Frequency n example : g(t) = sin(2 f t) + (1/3)sin(2 (3

Time and Frequency n example : g(t) = sin(2 f t) + (1/3)sin(2 (3 f) t) 7

Time and Frequency n example : g(t) = sin(2 f t) + (1/3)sin(2 (3

Time and Frequency n example : g(t) = sin(2 f t) + (1/3)sin(2 (3 f) t) = + 8

Time and Frequency n example : g(t) = sin(2 f t) + (1/3)sin(2 p(3

Time and Frequency n example : g(t) = sin(2 f t) + (1/3)sin(2 p(3 f) t) = + 9

Time and Frequency 1, a/2 < t < a/2 n example : g(t) =

Time and Frequency 1, a/2 < t < a/2 n example : g(t) = { 0, elsewhere 10

Time and Frequency n example : g(t) = = { 1, 0, a/2 <

Time and Frequency n example : g(t) = = { 1, 0, a/2 < t < a/2 elsewhere + = 11

Time and Frequency n example : g(t) = = { 1, 0, a/2 <

Time and Frequency n example : g(t) = = { 1, 0, a/2 < t < a/2 elsewhere + = 12

Time and Frequency n example : g(t) = = { 1, 0, a/2 <

Time and Frequency n example : g(t) = = { 1, 0, a/2 < t < a/2 elsewhere + = 13

Time and Frequency n example : g(t) = = { 1, 0, a/2 <

Time and Frequency n example : g(t) = = { 1, 0, a/2 < t < a/2 elsewhere + = 14

Time and Frequency n example : g(t) = = { 1, 0, a/2 <

Time and Frequency n example : g(t) = = { 1, 0, a/2 < t < a/2 elsewhere + = 15

Time and Frequency n example : g(t) = { 1, 0, a/2 < t

Time and Frequency n example : g(t) = { 1, 0, a/2 < t < a/2 elsewhere = 16

Time and Frequency n If the shape of the function is far from regular

Time and Frequency n If the shape of the function is far from regular wave its Fourier expansion will include infinite num of frequencies. = 17

Frequency domain n n Spectrum of freq. domain : range of freq. Bandwidth of

Frequency domain n n 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 18

Fourier transform n n Every periodic function can be represented as the sum of

Fourier transform n n Every periodic function can be represented as the sum of sine and cosine functions Transform a function between a time and freq. domain 19

Fourier transform Discrete Fourier Transform: 0 n-1 20

Fourier transform Discrete Fourier Transform: 0 n-1 20

FT for digitized image n n n Each pixel Pxy = point in 3

FT for digitized image n n n Each pixel Pxy = point in 3 D (z coordinate is value of color/gray level Each coefficient describes the 2 D sinusoidal function needed to reconstruct the surface In typical image neighboring pixels have “close” values surface is very smooth most FT coefficients small 21

Sampling theory n n n Image = continuous signal of intensity function I(t) Sampling:

Sampling theory n n n 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 22

Sampling theory n We can sample an image and reconstruct it without loss of

Sampling theory n We can sample an image and reconstruct it without loss of quality if we can : ¨ Transform I(t) function from to freq. Domain ¨ Find the max frequency fmax ¨ Sample I(t) at rate > 2 fmax ¨ Store the sampled values in a bitmap 2 fmax is called Nyquist rate 23

Sampling theory n Some loss of image quality because: ¨ fmax can be infinite.

Sampling theory n Some loss of image quality because: ¨ fmax can be infinite. n choose a value such that freq. > fmax do not contribute much (low amplitudes) ¨ Bitmap may be too small – not enough samples 24

Discrete Cosine Transform n A variant of discrete Fourier transform ¨ Real numbers ¨

Discrete Cosine Transform n A variant of discrete Fourier transform ¨ Real numbers ¨ Fast implementation ¨ Separable (row/column) 25

Discrete Cosine Transform n Definition of 2 D DCT: Image I(i, j) 1 i

Discrete Cosine Transform n Definition of 2 D DCT: Image I(i, j) 1 i N 1, 1 j N 2 ¨ Output: a new “image” B(u, v), each pixel stores the corresponding coefficient of the DCT ¨ Input: 26

Using DCT in JPEG n DCT on 8 x 8 blocks 27

Using DCT in JPEG n DCT on 8 x 8 blocks 27

Using DCT in JPEG n DCT – basis 28

Using DCT in JPEG n DCT – basis 28

Using DCT in JPEG n Block size ¨ small block faster n correlation exists

Using DCT in JPEG n Block size ¨ small block faster n correlation exists between neighboring pixels n ¨ large n n block better compression in smooth regions Power of 2 – for fast implementation 29

Using DCT in JPEG n n For smooth, slowly changing images most coefficients of

Using DCT in JPEG n n 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 30

Using DCT in JPEG n n The first coefficient B(0, 0) is the DC

Using DCT in JPEG n n 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 31

Image compression using DCT n n n DCT enables image compression by concentrating most

Image compression using DCT n n n 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 32

Bye-bye

Bye-bye