<<

University of British Columbia News • hw 1 solutions out CPSC 414 Computer Graphics – no more accepted as of right now Sampling • next week – Mon: midterm Week 7, Fri 17 Oct 2003 • no Mon office hours, I’m away at conferences • p1 demos – Wed: Prof. van de Panne on animation • sampling – Fri: TA Ahbijeet Ghosh on textures • correct p1 grades posted on web site now • project 1 – finish hall of fame demos

© Tamara Munzner 1 Week 6, Fri 10 Oct 03 © Tamara Munzner 2

Point Sampling Spatial Domain • multiply sample grid by image intensity to obtain a discrete set of points, or samples. • image as spatial signal y t i s n e t n I Pixel position across scanline Sampling Geometry Examples from Foley, van Dam, Feiner, and Hughes

Week 6, Fri 10 Oct 03 © Tamara Munzner 3 Week 6, Fri 10 Oct 03 © Tamara Munzner 4

Spatial Domain: Summing Waves Frequencies: Summing Spikes • represent spatial signal as sum of sine waves (varying frequency and phase shift) • very commonly used to represent sound “spectrum”

Week 6, Fri 10 Oct 03 © Tamara Munzner 5 Week 6, Fri 10 Oct 03 © Tamara Munzner 6

1 Frequency Domain Example • position: frequency spatial domain frequency domain • height: strength of each frequency – sine wave: impulse – square wave: infinite train of impulses

Week 6, Fri 10 Oct 03 © Tamara Munzner 7 Week 6, Fri 10 Oct 03 © Tamara Munzner 8

University of British Columbia Sampling Theorem CPSC 414 Computer Graphics continuous-time signal can be completely recovered from its samples iff the sampling Sampling rate is greater than twice the maximum frequency present in the signal.

- Claude Shannon

© Tamara Munzner 9 Week 6, Fri 10 Oct 03 © Tamara Munzner 10

Nyquist Rate Falling Below Nyquist Rate • the lower bound on the sampling rate • when sampling below Nyquist Rate, equals twice the highest frequency resulting signal looks like a lower- component in the image’s spectrum frequency one • this lower bound is the Nyquist Rate – this is !

Week 6, Fri 10 Oct 03 © Tamara Munzner 11 Week 6, Fri 10 Oct 03 © Tamara Munzner 12

2 Flaws with Nyquist Rate Nyquist Rate • samples may not align with peaks

Week 6, Fri 10 Oct 03 © Tamara Munzner 13 Week 6, Fri 10 Oct 03 © Tamara Munzner 14

Nyquist and Checkerboards Band-limited Signals • point sampled 1D checkerboard: aliases • if you know a function contains no components of frequencies higher than x – band-limited implies original function will not require any ideal functions with frequencies greater than x • unweighted area sample: still have aliasing – facilitates reconstruction – avoids Nyquist Limit mistakes • to lower Nyquist rate, remove high frequencies from image: low-pass filter – only low frequencies remain: band-limited Week 6, Fri 10 Oct 03 © Tamara Munzner 15 Week 6, Fri 10 Oct 03 © Tamara Munzner 16

Low-Pass Filtering Low-Pass Filtering

Week 6, Fri 10 Oct 03 © Tamara Munzner 17 Week 6, Fri 10 Oct 03 © Tamara Munzner 18

3 Filtering Filtering in Spatial Domain • blurring or averaging pixels together • low pass – blur g(y) Integrate over y Calculate integral of one f(x) h(x) function, f(x) by a sliding second function g(x-y).

Increment Known as Convolution. x • high pass – edge finding h(x) = f ⊗ g = — f (x)g(x − y)dy

Week 6, Fri 10 Oct 03 © Tamara Munzner 19 Week 6, Fri 10 Oct 03 © Tamara Munzner 20

Common Filters Filtering in Frequency Domain • multiply signal’s spectrum by pulse function

Frequency Image Filter Image domain Fourier Fourier Transform Lowpass filter Transform

Highpass filter

Week 6, Fri 10 Oct 03 © Tamara Munzner 21 Week 6, Fri 10 Oct 03 © Tamara Munzner 22

Dualities Sinc Function – inverse relationship between size • sinc (pulse) function is common filter: • T large -> 2/T small – sinc(x) = sin (πx)/πx – infinite in frequency domain T 2π/T Spatial Domain Frequency Domain

t ω Spatial domain Frequency domain

Week 6, Fri 10 Oct 03 © Tamara Munzner 23 Week 6, Fri 10 Oct 03 © Tamara Munzner 24

4 Sampling in Spatial Domain Sampling in Frequency Domain • Q: what is sampling (i.e. evaluating a continuous • multiple copies of spectrum function at evenly spaced points)? • example: given spectrum S(ω) of a signal s(t) • A: multiplication of the sample with a regular train of delta functions (spikes). S(ω)

-ω0 ω0 ω

Week 6, Fri 10 Oct 03 © Tamara Munzner 25 Week 6, Fri 10 Oct 03 © Tamara Munzner 26

Sampling in Frequency Domain Sampling in Frequency Domain

• multiple shifted copies of S(ω) are added • if T is too large (2π/T is small), overlap occurs up during sampling – this is aliasing • if 2π/T is large enough (T is small enough) – individual spectrum copies do not overlap S(ω)*P(ω)

– depends on maximum frequency ω0 in s(t) S(ω)*P(ω) S(ω)* (ω) 2π/T

2π/T ω

ω Week 6, Fri 10 Oct 03 © Tamara Munzner 27 Week 6, Fri 10 Oct 03 © Tamara Munzner 28

How do we remove aliasing ? leads to aliasing. • perfect solution - prefilter with perfect bandpass filter.

No aliasing.

Aliased example Perfect bandpass Samples are too close Spurious components : together in f. Cause of aliasing.

Week 6, Fri 10 Oct 03 © Tamara Munzner 29 Week 6, Fri 10 Oct 03 © Tamara Munzner 30

5 How do we remove aliasing ? How do we remove aliasing ?

• perfect solution - prefilter with perfect • cheaper solution : take multiple samples for bandpass filter. each pixel and average them together → – difficult/Impossible to do in frequency domain . • convolve with sinc function in space • can weight them towards the centre → domain weighted average sampling – optimal filter - better than area sampling. • stochastic sampling – sinc function is infinite !! • importance sampling – computationally expensive Removing aliasing is called antialiasing

Week 6, Fri 10 Oct 03 © Tamara Munzner 31 Week 6, Fri 10 Oct 03 © Tamara Munzner 32

Weighted Sampling Stochastic Supersampling

• multiple samples per pixel • high frequency noise preferable to aliases

Week 6, Fri 10 Oct 03 © Tamara Munzner 33 Week 6, Fri 10 Oct 03 © Tamara Munzner 34

Importance Sampling

Week 6, Fri 10 Oct 03 © Tamara Munzner 35

6