<<

CS148: Introduction to Graphics and Imaging Basic Processing: Sampling and

Key Concepts

Frequency space Filters and Sampling Aliasing Antialiasing

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 1 Frequency Space

Spatial and

Spatial Domain Frequency Domain (Center is fx = fy = 0)

Can convert from one to the other using the CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 2 Filtering in Frequency Space

Spatial Domain Frequency Domain

Multiply filter times image in frequency space In this case, the filter removes high frequencies CS148 Lecture 15 Pat Hanrahan, Fall 2009

Filtering in Frequency Space

Spatial Domain Frequency Domain

Multiply filter times image in frequency space In this case, the filter removes low frequencies CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 3 Filtering in Frequency Space

Spatial Domain Frequency Domain

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Filtering in Frequency Space

Spatial Domain Frequency Domain

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 4 Filters = Convolution

Convolution

Signal / Image

1 3 0 4 2 1

Filter

1 2

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 5 Convolution

1 3 0 4 2 1

1 2

1 * 1 + 3 * 2 = 7

7

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Convolution

1 3 0 4 2 1

1 2

3 * 1 + 0 * 2 = 3

7 3

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 6 Convolution

1 3 0 4 2 1

1 2

0 * 1 +4 * 2 = 8

7 3 8

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Convolution Theorem

A filter can be implemented in the spatial domain using convolution A filter can also be implemented in the frequency domain  Convert image to frequency domain  Convert filter to frequency domain  Multiply filter times image in frequency domain  Convert result to the spatial domain  This works because of the Filter properties are easier to understand in the frequency domain

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 7 Box Filter

1 1

1 1

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Box Filter = Low-Pass Filter

Spatial Domain Frequency Domain

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 8 Wider Filters, Lower Frequencies

Spatial Domain Frequency Domain

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Size of Filter

As a filter is localized in space, it spreads out in frequency Conversely, as a filter is localized in frequency, it spreads out in space

A box filter is very localized in space; it has infinite extent in frequency space A small box filter has more high frequencies than a larger box filter

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 9 Efficiency?

When would it be faster to apply the filter in the spatial domain?

When would it be faster to apply the filter in the frequency domain?

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Sampling

Page 10 Image Generation = Sampling

Rasterization is performed by testing whether a point is inside a triangle

More generally, evaluate a function at a point !for( int x = 0; x < xmax; x++ )! !!for( int y = 0; y < ymax; y++ )! !! I[x][y] = f( float(x), float(y));!

Take a continuous function f and convert to set of samples I, a discrete representation of the func.

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Aliasing

Page 11 Zone Plate

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Zone Plate

Aliases

(0,0)

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 12 Wagon Wheel Effect

http://www.michaelbach.de/ot/mot_wagonWheel /

“Aliases”

Two frequencies are indistinguishable

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 13 Nyquist Frequency

Definition: Sampling period Ts Definition: The Nyquist frequency is ½ the sampling frequency = 1/(2 Ts)

A periodic signal above the Nyquist frequency cannot be distinguished from a periodic signal below the Nyquist frequency

Indistinguishable frequencies look alike Hence, they are called aliases

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Sampling in

All of computer graphics involve sampling

Artifacts due to sampling - Aliasing  Jaggies – sampling in space  Flickering small objects – sampling in space  Moire – sampling texture coordinates  Sparkling highlights – sampling normals  Temporal strobing – sampling in time

Preventing these artifacts - Antialiasing

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 14 Jaggies

Retort sequence by Don Mitchell

Staircase pattern or jaggies CS148 Lecture 15 Pat Hanrahan, Fall 2009

Moire Pattern

http://commons.wikimedia.org/wiki/File:Moire-%28quadrat%29-1.png

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 15 Zone Plate – Moire Patterns

Aliases

(0,0)

Moire pattern (sum of signal and aliased signal)

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Antialiasing

Page 16 Antialiasing

Simple idea:

Remove frequencies above the Nyquist frequency before sampling

How? Filtering before sampling

Filter during rasterization

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Prefiltering by Computing Coverage

Pixel Area = Box Filter

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 17 Point- vs. Area-Sampled

Point Area

Checkerboard sequence by Tom Duff CS148 Lecture 15 Pat Hanrahan, Fall 2009

Supersampling

Take a set of samples and average them together

4 x 4

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 18 Point-sampling vs. Super-sampling

Point 4x4 Super-sampled

Checkerboard sequence by Tom Duff CS148 Lecture 15 Pat Hanrahan, Fall 2009

Area-Sampling vs. Super-sampling

Exact Area 4x4 Super-sampled

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 19 Antialiasing

Jaggies Prefilter

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Antialiasing vs. Blurred Aliases

Blurred Jaggies Prefilter

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 20 Things to Remember

Convolutions Frequency domain vs. spatial domain Filtering in the spatial domain vs. frequency domain Sampling converts continuous image to discrete image Image generation involves sampling May also sample geometry, motion, … Nyquist frequency is ½ the sampling rate Frequencies above the Nyquist frequency appear as other frequencies – aliasess Antialiasing – Filter before sampling

CS148 Lecture 15 Pat Hanrahan, Fall 2009

Page 21