Title: Computer Graphics
1Computer Graphics
2Motivation Image compression
What linear combination of 8x8 basis signals
produces an 8x8 block in the image?
3The plan today
- Fourier Transform (FT).
- Discrete Cosine Transform (DCT).
4What 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)
5What 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
6Periodic function
- Definition g(t) is periodic if exists P such
that g(tP) g(t) - Period of a function smallest constant P that
satisfies g(tP) g(t)
7Attributes 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
8Time and Frequency
- example g(t) sin(2pft) (1/3)sin(2p(3f)t)
9Time and Frequency
- example g(t) sin(2pft) (1/3)sin(2p(3f)t)
10Time and Frequency
- example g(t) sin(2pft) (1/3)sin(2p(3f)t)
11Time and Frequency
1, -a/2 lt t lt a/2 0, elsewhere
12Time and Frequency
1, -a/2 lt t lt a/2 0, elsewhere
13Time and Frequency
1, -a/2 lt t lt a/2 0, elsewhere
14Time and Frequency
1, -a/2 lt t lt a/2 0, elsewhere
15Time and Frequency
1, -a/2 lt t lt a/2 0, elsewhere
16Time and Frequency
1, -a/2 lt t lt a/2 0, elsewhere
17Time and Frequency
1, -a/2 lt t lt a/2 0, elsewhere
A (1/k)sin(2pkft)
18Time 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(2pkft)
19Frequency 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
20Fourier transform
- Every periodic function can be represented as
the sum of sine and cosine functions - Transform a function between a time and freq.
domain
G(f) g(t)cos(2pft) - i sin(2pft)dt
g(t) G(f)cos(2pft) i sin(2pft)df
21Fourier transform
G(f) (1/n) g(t)cos(2pft/n) - i
sin(2pft/n) , 0ltfltn-1
g(t) (1/n) G(f)cos(2pft/n) i
sin(2pft/n) , 0lttltn-1
22FT 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
23Sampling 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 -
24Sampling 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 gt 2fm
- - Store the sampled values in a bitmap
-
25Sampling theory
- Some loss of image quality because
- - fm can be infinite choose a value s.t freq. gt
fm do not contribute much (low amplitudes) - - Bitmap may be too small
- 2fm is Nyquist rate
-
26Fourier 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
27Discrete Cosine Transform
- A variant of discrete Fourier transform
- - Real numbers
- - Fast implementation
- -Separable (row/column)
28Discrete Cosine Transform
f0 1 f17
G (½) C P cos((2t1)fp/16) , C
f
t
f
f
- Fourier transform on 8 points
G P cos(2pft/8) i P sin(2pft/8) ,
f0,1,,7
t
f
t
29Discrete 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
30Discrete Cosine Transform
f0 1 f17
G (½) C P cos((2t1)fp/16) , C
f
t
f
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
31Discrete Cosine Transform
The inverse DCT
P (½) C G cos((2t1)jp/16) ,
t0,1,,7
j
t
j
32Discrete Cosine Transform
G C C Pxy cos((2x1)ip/2n)cos((2y
1)jp/2n)
j
i
ij
P ¼ C C Gij cos((2x1)ip/16)
cos((2y1)jp/16)
xy
j
i
C f
f0 1 f17
33Using DCT in JPEG
34Using 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
35Using DCT in JPEG
36Using DCT in JPEG
- For almost flat surface most Gij0
- 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.
37Using DCT in JPEG
- 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
38Image compression using DCT
- 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
39See you next time