Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

40
Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007 http://graphics.stanford.edu/courses/cs248-07/
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    212
  • download

    0

Transcript of Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

Page 1: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

Sampling and Aliasing

Kurt Akeley

CS248 Lecture 3

2 October 2007

http://graphics.stanford.edu/courses/cs248-07/

Page 2: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Aliasing

Aliases are low frequencies in a rendered image that are due to

higher frequencies in the original image.

Page 3: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Jaggies

Are jaggies due to aliasing? How?

Original:

Rendered:

Page 4: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Demo

Page 5: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

What is a point sample (aka sample)?

An evaluation

At an infinitesimal point (2-D)

Or along a ray (3-D)

What is evaluated

Inclusion (2-D) or intersection (3-D)

Attributes such as distance and color

Page 6: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Why point samples?

Clear and unambiguous semantics

Matches theory well (as we’ll see)

Supports image assembly in the framebuffer

will need to resolve visibility based on distance, and this works well with point samples

Anything else just puts the problem off

Exchange one large, complex scene for many small, complex scenes

Page 7: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Fourier theory

“Fourier’s theorem is not only one of the most beautiful results of modern analysis, but it may be said to furnish an indispensable instrument in the treatment of nearly every recondite question in modern physics.”

-- Lord Kelvin

Page 8: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Reference sources

Marc Levoy’s notes

Ronald N. Bracewell, The Fourier Transform and its Applications, Second Edition, McGraw-Hill, Inc., 1978.

Private conversations with Pat Hanrahan

MATLAB

Page 9: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Ground rules

You don’t have to be an engineer to get this

We’re looking to develop instinct / understanding

Not to be able to do the mathematics

We’ll make minimal use of equations

No integral equations

No complex numbers

Plots will be consistent

Tick marks at unit distances

Signal on left, Fourier transform on the right

Page 10: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Dimensions

1-D

Audio signal (time)

Generic examples (x)

2-D

Image (x and y)

3-D

Animation (x, y, and time)

All examples in this presentation are 1-D

Page 11: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Fourier series

Any periodic function can be exactly represented by a (typically infinite) sum of harmonic sine and cosine

functions.

Harmonics are integer multiples of the fundamental frequency

Page 12: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Fourier series example: sawtooth wave

……

( )( )

( )1

1

12sin

n

n

f x n xn

pp

=

-= å

1

1-1

Page 13: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Sawtooth wave summation

Harmonics Harmonic sums

1

2

3

n

Page 14: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Sawtooth wave summation (continued)

Harmonics Harmonic sums

5

10

50

n

Page 15: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Fourier integral

Any function (that matters in graphics) can be exactly

represented by an integration of sine and cosine functions.

Continuous, not harmonic

But the notion of harmonics will continue to be useful

Page 16: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Basic Fourier transform pairs

1 ( )sd

f(x) F(s)

( )cos xp II(s)

Page 17: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Reciprocal property

Swapped left/right

from previous

slide

f(x) F(s)

1

( )cos xp

( )sd

II(s)

Page 18: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Scaling theorem

( )cos 2 xp

cos2

xpæ ö÷ç ÷ç ÷çè øII(2s)

II(s/2)

f(x) F(s)

Page 19: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Band-limited transform pairs

( )sÙ

F(s)f(x)

sinc(x)( )sin x

x

p

p( )sÕ

sinc2(x)

Page 20: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Finite / infinite extent

If one member of the transform pair is finite, the other is infinite

Band-limited infinite spatial extent

Finite spatial extent infinite spectral extent

Page 21: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Convolution

( ) ( ) ( ) ( )f x g x f u g x u du¥

- ¥

* = -ò

Page 22: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Convolution example

*

=

Page 23: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Convolution theorem

Let f and g be the transforms of f and g. Then

f g f g* = ×

f g f g× = *

f g f g* = ×

f g f g× = *

Something difficult to do in one domain (e.g., convolution) may be

easy to do in the other (e.g., multiplication)

Page 24: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Sampling theory

x

=

*

=

F(s)f(x)

Spectrum is replicated an

infinite number of

times

Page 25: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Reconstruction theory

x

=

*

=

F(s)f(x)

sinc

Page 26: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Sampling at the Nyquist rate

x

=

*

=

F(s)f(x)

Page 27: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Reconstruction at the Nyquist rate

x

=

*

=

F(s)f(x)

Page 28: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Sampling below the Nyquist rate

x

=

*

=

F(s)f(x)

Page 29: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Reconstruction below the Nyquist rate

x

=

*

=

F(s)f(x)

Page 30: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Reconstruction error

Original Signal

UndersampledReconstruction

Page 31: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Reconstruction with a triangle function

x

=

*

=

F(s)f(x)

Page 32: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Reconstruction error

Original Signal

TriangleReconstruction

Page 33: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Reconstruction with a rectangle function

x

=

*

=

F(s)f(x)

Page 34: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Reconstruction error

Original Signal

RectangleReconstruction

Page 35: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Sampling a rectangle

x

=

*

=

F(s)f(x)

Page 36: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Reconstructing a rectangle (jaggies)

x

=

*

=

F(s)f(x)

Page 37: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Sampling and reconstruction

Aliasing is caused by

Sampling below the Nyquist rate,

Improper reconstruction, or

Both

We can distinguish between

Aliasing of fundamentals (demo)

Aliasing of harmonics (jaggies)

Page 38: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Summary

Jaggies matter

Create false cues

Violate rule 1

Sampling is done at points (2-D) or along rays (3-D)

Sufficient for depth sorting

Matches theory

Fourier theory explains jaggies as aliasing. For correct reconstruction:

Signal must be band-limited

Sampling must be at or above Nyquist rate

Reconstruction must be done with a sinc function

Page 39: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

Assignments

Before Thursday’s class, read

FvD 3.17 Antialiasing

Project 1:

Breakout: a simple interactive game

Demos Wednesday 10 October

Page 40: Sampling and Aliasing Kurt Akeley CS248 Lecture 3 2 October 2007

CS248 Lecture 3 Kurt Akeley, Fall 2007

End