sampling and reconstruction - computer...
TRANSCRIPT
Page 1
Sampling and Reconstruction
The sampling and reconstruction process
Real world: continuous
Digital world: discrete
Basic signal processing
Fourier transforms
The convolution theorem
The sampling theorem
CS348B Lecture 9 Pat Hanrahan, Spring 2009
The sampling theorem
Aliasing and antialiasing
Uniform supersampling
Stochastic sampling
Imagers = Signal Sampling
All imagers convert a continuous image to a discrete sampled image by integrating over the active “area” of a sensor.
Examples:
Retina: photoreceptors
CCD
( , , ) ( ) ( )cosT A
R L x t P x S t dAd dtω θ ωΩ
= ∫∫∫∫∫
CS348B Lecture 9 Pat Hanrahan, Spring 2009
CCD array
We propose to do this integral using Monte Carlo Integration
Page 2
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:
DACs: sample and hold
Cathode ray tube: phosphor spot and grid
CS348B Lecture 9 Pat Hanrahan, Spring 2009
DAC CRT
Jaggies
Retort sequence by Don Mitchell
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Staircase pattern or jaggies
Page 3
Sampling in Computer Graphics
Artifacts due to sampling - Aliasing
Jaggies
Moire
Flickering small objects
Sparkling highlights
Temporal strobing
Preventing these artifacts - Antialiasing
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Preventing these artifacts Antialiasing
Basic Signal Processing
Page 4
Fourier Transforms
Spectral representation treats the function as a weighted sum of sines and cosines
Each function has two representationsEach function has two representations
Spatial domain - normal representation
Frequency domain - spectral representation
The Fourier transform converts between the spatial and frequency domain
∞
CS348B Lecture 9 Pat Hanrahan, Spring 2009
SpatialDomain
FrequencyDomain
( ) ( )
1( ) ( )2
i x
i x
F f x e dx
f x F e d
ω
ω
ω
ω ωπ
−
−∞
∞
−∞
=
=
∫
∫
Spatial and Frequency Domain
Spatial Domain Frequency Domain
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Page 5
More Examples
Spatial Domain Frequency Domain
CS348B Lecture 9 Pat Hanrahan, Spring 2009
More Examples
Spatial Domain Frequency Domain
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Page 6
More Examples
Spatial Domain Frequency Domain
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Pat’s Frequencies
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Page 7
Pat’s Frequencies
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Convolution
Definition
( ) ( ) ( )h x f g f x g x x dx′ ′ ′= ⊗ = −∫Convolution Theorem: Multiplication in the
frequency domain is equivalent to convolution in the space domain.
S t i Th M lti li ti i th
f g F G⊗ ↔ ×
∫
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Symmetric Theorem: Multiplication in the space domain is equivalent to convolution in the frequency domain.
f g F G× ↔ ⊗
Page 8
The Sampling Theorem
Sampling: Spatial Domain
)(xf
× =
∑∞
TfT )()(δ
CS348B Lecture 9 Pat Hanrahan, Spring 2009
III( ) ( )n
n
x x nTδ=∞
=−∞
= −∑∑−∞=
−n
nTfnTx )()(δ
Page 9
Sampling: Frequency Domain
)(ωF
⊗ =
CS348B Lecture 9 Pat Hanrahan, Spring 2009
∑∞
−∞=
−=n
T TnIII )/()(/1 ωδω
Reconstruction: Frequency Domain
× =
Rect function of width T:
CS348B Lecture 9 Pat Hanrahan, Spring 2009
)(/1 xT∏
⎪⎩
⎪⎨
⎧
>
≤=∏
20
21
)( Tx
TxxT
Page 10
Reconstruction: Spatial Domain
=⊗
CS348B Lecture 9 Pat Hanrahan, Spring 2009
sincsinc (x/T)x
xxππsin)( =
Sinc function:
Sampling and Reconstruction
= =
×⊗
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Page 11
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 samples
without loss of information, if the original
signal has no frequencies above 1/2 the
Sampling frequency
CS348B Lecture 9 Pat Hanrahan, Spring 2009
p g q y
For a given bandlimited function, the rate it must be sampled is called the Nyquist Frequency
Aliasing
Page 12
Undersampling: Aliasing
= =
⊗ ×
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Sampling a “Zone Plate”
2 2sin x y+y
Zone plate:
Sampled at 128x128
x
Sampled at 128x128Reconstructed to 512x512Using a 30-wideKaiser windowed sinc
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Left rings: part of signalRight rings: prealiasing
Page 13
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 i d d b liintroduced by sampling
Unfortunately,
The sinc has infinite extent and we must use simpler filters with finite extents. Physical processes in particular do not reconstruct with sincs
CS348B Lecture 9 Pat Hanrahan, Spring 2009
The sinc may introduce ringing which are perceptually objectionable
Sampling a “Zone Plate”
2 2sin x y+y
Zone plate:
Sampled at 128x128
x
Sampled at 128x128Reconstructed to 512x512Using optimal cubic
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Left rings: part of signalRight rings: prealiasingMiddle rings: postaliasing
Page 14
Mitchell Cubic Filter
3 2
3 2
(12 9 6 ) ( 18 12 6 ) (6 2 ) 11( ) ( 6 ) (6 30 ) ( 12 48 ) (8 24 ) 1 26
0
B C x B C x B xh x B C x B C x B C x B C x
otherwise
⎧ − − + − + + + − <⎪= − − + + + − − + + < <⎨⎪⎩ 0 otherwise⎩
Properties:
( ) 1n
n
h x=∞
=−∞
=∑
Good: (1/ 3,1/ 3)
CS348B Lecture 9 Pat Hanrahan, Spring 2009
From Mitchell and Netravali
B-spline: (1,0)Catmull-Rom: (0,1/ 2)
Aliasing
Prealiasing: due to sampling under Nyquist rate
Postaliasing: due to use of imperfectPostaliasing: due to use of imperfect reconstruction filter
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Page 15
Antialiasing
Antialiasing
Antialiasing = Preventing aliasing
1 A l ti ll filt th i l1. Analytically prefilter the signalSolvable for points, lines and polygonsNot solvable in generale.g. procedurally defined images
2. Uniform supersampling and resample3. Nonuniform or stochastic sampling
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Page 16
Antialiasing by Prefiltering
= =
⊗×
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Frequency Space
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
Pi l S l∑
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Samples Pixel
s ss
Pixel w Sample= ⋅∑
Page 17
Point vs. Supersampled
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Point 4x4 Supersampled
Checkerboard sequence by Tom Duff
Analytic vs. Supersampled
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Exact Area 4x4 Supersampled
Page 18
Distribution of Extrafoveal Cones
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Monkey eye cone distribution
Fourier transform
Yellot theoryAliases replaced by noiseVisual system less sensitive to high freq noise
Non-uniform Sampling
Intuition
Uniform sampling
The spectrum of uniformly spaced samples is also aThe spectrum of uniformly spaced samples is also a set of uniformly spaced spikes
Multiplying the signal by the sampling pattern corresponds to placing a copy of the spectrum at each spike (in freq. space)
Aliases are coherent, and very noticable
Non-uniform sampling
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Samples at non-uniform locations have a different spectrum; a single spike plus noise
Sampling a signal in this way converts aliases into broadband noise
Noise is incoherent, and much less objectionable
Page 19
Jittered Sampling
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Add uniform random jitter to each sample
Jittered vs. Uniform Supersampling
CS348B Lecture 9 Pat Hanrahan, Spring 2009
4x4 Jittered Sampling 4x4 Uniform
Page 20
Analysis of Jitter
( ) ( )n
nn
s x x xδ=∞
=−∞
= −∑ ~ ( )nj j x
Non-uniform sampling Jittered sampling
n= ∞
n nx nT j= + 1 1/ 2( )
0 1/ 2
( ) sinc
xj x
x
J ω ω
⎧ ≤⎪= ⎨ >⎪⎩=
1 2 2n=−∞
CS348B Lecture 9 Pat Hanrahan, Spring 2009
2 2
2
2
1 2 2( ) 1 ( ) ( ) ( )
1 1 sinc ( )
n
n
nS J JT T T
T
π πω ω ω δ ω
ω δ ω
=−∞
=−∞
⎡ ⎤= − + −⎣ ⎦
⎡ ⎤= − +⎣ ⎦
∑
Poisson Disk Sampling
CS348B Lecture 9 Pat Hanrahan, Spring 2009
Dart throwing algorithm