Sampling and Reconstruction - Computer...

16
Page 1 CS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling and Reconstruction The sampling and reconstruction process n Real world: continuous n Digital world: discrete Basic signal processing n Fourier transforms n The convolution theorem n The sampling theorem Aliasing and antialiasing n Uniform supersampling n Nonuniform supersampling CS348B Lecture 7 Pat Hanrahan, Spring 2000 Imagers = Signal Sampling All imagers convert a continuous image to a discrete sampled image by integrating over the active “area” of a sensor. Examples: n Retina: photoreceptors n CCD array n Vidicon: phosphors Virtual “computer graphics” cameras do not integrate, instead they simply sample ... ∫∫∫∫∫ = t A dt d dA t S x P t x L R w w q w cos ) ( ) ( ) , , (

Transcript of Sampling and Reconstruction - Computer...

Page 1: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 1

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Sampling and Reconstruction

The sampling and reconstruction processn Real world: continuous

n Digital world: discrete

Basic signal processing

n Fourier transforms

n The convolution theorem

n The sampling theoremAliasing and antialiasing

n Uniform supersampling

n Nonuniform supersampling

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Imagers = Signal Sampling

All imagers convert a continuous image to a discrete sampled image by integrating over the active “area” of a sensor.

Examples:n Retina: photoreceptorsn CCD arrayn Vidicon: phosphors

Virtual “computer graphics” cameras do not integrate,instead they simply sample ...

∫ ∫∫ ∫∫=t A

dtddAtSxPtxLRω

ωθω cos)()(),,(

Page 2: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 2

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Displays = Signal Reconstruction

All physical displays recreate a continuous image from a discrete sampled image by using a finite sized source of light for each pixel.

Examples:

n DAC’s: sample and holdn Cathode ray tube: phosphor spot and grid

DAC CRT

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Sampling in Computer Graphics

Artifacts due to sampling - Aliasingn Jaggies

n Moire

n Flickering small objects

n Sparkling highlights

n Temporal strobing

Preventing these artifacts - Antialiasing

Page 3: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 3

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Jaggies

Retort sequence by Don Mitchell

Staircase pattern or jaggies

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Spectral Analysis / Fourier Transforms

Spectral representation treats the function as a weighted sum of sines and cosines

Each function has two representations

n Spatial (time) domain - normal representationn Frequency domain - spectral representation

The Fourier transform converts between the spatial and frequency domain

SpatialDomain

FrequencyDomain

∫∞

∞−

∞−

=

=

ωωπ

ω

ω

ω

deFxf

dxexfF

xi

xi

)(21

)(

)()(

Page 4: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 4

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Spatial and Frequency Domain

Spatial Domain Frequency Domain

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Convolution

Definition

Convolution Theorem: Multiplication in the frequency domain is equivalent to convolution in the space domain.

Symmetric Theorem: Multiplication in the space domain is equivalent to convolution in the frequency domain.

GFgf ×↔⊗

GFgf ⊗↔×

∫ ′′−′=⊗= xdxxgxfgfxh )()()(

Page 5: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 5

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Sampling: Spatial Domain

× =

∑∞=

−∞=

−=n

n

nTxx )()III( δ Tf

Tf sss

ππω

22

1===

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Sampling: Frequency Domain

∑∞=

−∞=

−=n

nsn )()III( ωωδω

=

Page 6: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 6

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Reconstruction: Frequency Domain

× =

>≤

=2

1

21

01

)II(xx

x

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Reconstruction: Spatial Domain

=⊗

xx

πsinsinc =

Page 7: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 7

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Sampling and Reconstruction

×⊗

= =

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Sampling Theorem

This result if known as the Sampling Theorem and is due to Claude Shannon who first discovered it in 1949

A signal can be reconstructed from its sampleswithout loss of information, if the original signal

has no frequencies above 1/2 the sampling

frequency

For a given bandlimited function, the rate at which it must be sampled is called the Nyquist Frequency

Page 8: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 8

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Undersampling: Aliasing

⊗ ×

= =

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Sampling a “Zone Plate”

22sin yx +y

x

Zone plate:

Sampled at 128x128Reconstructed to 512x512

Left rings: part of signalRight rings: prealiasingMiddle rings: postaliasing

Page 9: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 9

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Ideal Reconstruction

Ideally, use a perfect low-pass filter - the sinc function -to bandlimit the sampled signal and thus remove all copies of the spectra introduced by sampling

Unfortunately,

n The sinc has infinite extent and we must use simpler filters with finite extents. Physical processes in particular do not reconstruct with sincs

n The sinc may introduce ringing which are perceptually objectionable

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Mitchell Cubic Filter

otherwise

xx

CBxCBxCBxCBBxCBxCB

xh 211

0

)248()4812()306()6()26()61218()6912(

61)( 23

23

<<<

++−−+++−−

−+++−+−−=

Properties:

1)( =∑∞=

−∞=

n

n

xh

From Mitchell and NetravaliLook at other figures in that paper

)3/1,3/1(:Good

)2/1,0(:Rom-Catmull)0,1(:spline-B

Page 10: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 10

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Aliasing and Antialiasing

If the scene contains frequencies greater than theNyquist Frequency, then we have a aliasing problem

Results of aliasing:n Jaggiesn Moiren Flickering small objectsn Sparkling highlightsn Temporal strobing

Preventing aliasing or antialiasing:1. Analytically prefilter the signal2. Uniform supersampling and resample3. Nonuniform or stochastic sampling

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Antialiasing by Prefiltering

⊗ ×

= =

Page 11: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 11

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Antialiasing by Prefiltering

Ideally, low-pass with a perfect filter (a sinc function) tobandlimit the function to the Nyquist sampling rate.

Unfortunately, the sinc has infinite extent and we must use simpler filters (like a box filter, or area average).

Practically:n Constant colored polygonal fragments doable

n Complex environments not doable

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Uniform Supersampling

Increasing the sampling rate moves each copy of the spectra further apart, potentially reducing the overlap and thus aliasing

Resulting samples must be resampled (filtered) to image sampling rate

Samples Pixel

∑ ⋅=s

ss SamplewPixel

Page 12: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 12

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Point vs. Supersampled

Point 4x4 Supersampled

Checkerboard sequence by Tom Duff

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Analytic vs. Supersampled

Exact Area 4x4 Supersampled

Page 13: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 13

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Distribution of Extrafoveal Cones

Monkey eye cone distribution Fourier transform

Yellot theory

n Aliases replaced by noise

n Visual system less sensitive to high frequency noise

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Non-uniform Sampling

Intuition

Uniform sampling

n The spectrum of uniformly spaced samples is also a set of uniformly spaced spikes

n Multiplying the signal by the sampling pattern corresponds to placing a copy of the spectrum at each spike (in freq. space)

n Aliases are coherent, and very noticable

Non-uniform sampling

n Samples at non-uniform locations have a different spectrum; a single spike plus noise

n Sampling a signal in this way converts aliases into broadband noise

n Noise is incoherent, and much less objectionable

Page 14: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 14

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Jittered Sampling

Add uniform random jitter to each sample

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Jittered vs. Uniform Supersampling

Jittered Sampling 4x4 Uniform

Page 15: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 15

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Analysis of Jitter

∑∞=

−∞=−=

n

nnxxxs )()( δ

nn jnTx +=

ωω sinc)(

2/102/11

)(

)(~

=

>≤

=

J

xx

xj

xjjn

[ ][ ] )(sinc1

1

)2

()(2

)(11

)(

2

2

2

2

ωδω

πωδωπωω

+−=

−+−= ∑−∞=

−∞=

T

Tn

JT

JT

Sn

n

Non-uniform sampling Jittered sampling

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Poisson Disk Sampling

Dart throwing algorithm

Page 16: Sampling and Reconstruction - Computer Graphicsgraphics.stanford.edu/courses/cs348b-00/lectures/lecture07/sampling.I.pdfCS348B Lecture 7 Pat Hanrahan, Spring 2000 Sampling Theorem

Page 16

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Filtering Nonuniform Samples

1. Reconstruction

2. Filtering further attenuates high frequency noise

3. Problematical if samples are clumpy

∑∑ ⋅

=

sss

sss

ss

yxw

yxSyxwP

),(

),(),(

Note: For jittered samples may approximate with filter coefficients at centers of each cell

CS348B Lecture 7 Pat Hanrahan, Spring 2000

Tiling