Aliasing Sampling and Reconstruction - TU Wien · 3 Square Wave & Scanline Eduard Gröller, Thomas...

9
1 Sampling and Reconstruction Institute of Computer Graphics and Algorithms Vienna University of Technology Peter Rautek, Eduard Gröller, Thomas Theußl Motivation Theory and practice of sampling and reconstruction Aliasing Understanding the problem Handling the problem E l Examples: Photography/Video Rendering Computed Tomography Collision detection Eduard Gröller, Thomas Theußl, Peter Rautek 1 Overview Introduction Tools for Sampling and Reconstruction Fourier Transform Convolution (dt.: Faltung) Convolution Theorem Filtering Filtering Sampling The mathematical model Reconstruction Sampling Theorem Reconstruction in Practice Eduard Gröller, Thomas Theußl, Peter Rautek 2 Image Data Eduard Gröller, Thomas Theußl, Peter Rautek 3 Demo - Scan Lines - Sampling http://www.cs.brown.edu/exploratories/freeSoftware/repository/edu/brown/cs/exploratories/applets/sampling/introduction_to_sampling_java_browser.html Image Storage and Retrieval Eduard Gröller, Thomas Theußl, Peter Rautek 4 Sampling Problems Eduard Gröller, Thomas Theußl, Peter Rautek 5

Transcript of Aliasing Sampling and Reconstruction - TU Wien · 3 Square Wave & Scanline Eduard Gröller, Thomas...

Page 1: Aliasing Sampling and Reconstruction - TU Wien · 3 Square Wave & Scanline Eduard Gröller, Thomas Theußl, Peter Rautek 12 Fourier Transform Yields complex functions for frequency

1

Sampling and Reconstruction

Institute of Computer Graphics and Algorithms

Vienna University of Technology

Peter Rautek, Eduard Gröller, Thomas Theußl

Motivation

Theory and practice of sampling and reconstructionAliasing

Understanding the problem Handling the problem

E lExamples:Photography/VideoRenderingComputed TomographyCollision detection

Eduard Gröller, Thomas Theußl, Peter Rautek 1

OverviewIntroductionTools for Sampling and Reconstruction

Fourier TransformConvolution (dt.: Faltung)Convolution TheoremFilteringFiltering

SamplingThe mathematical model

Reconstruction Sampling TheoremReconstruction in Practice

Eduard Gröller, Thomas Theußl, Peter Rautek 2

Image Data

Eduard Gröller, Thomas Theußl, Peter Rautek 3

Demo - Scan Lines- Sampling

http://www.cs.brown.edu/exploratories/freeSoftware/repository/edu/brown/cs/exploratories/applets/sampling/introduction_to_sampling_java_browser.html

Image Storage and Retrieval

Eduard Gröller, Thomas Theußl, Peter Rautek 4

Sampling Problems

Eduard Gröller, Thomas Theußl, Peter Rautek 5

Page 2: Aliasing Sampling and Reconstruction - TU Wien · 3 Square Wave & Scanline Eduard Gröller, Thomas Theußl, Peter Rautek 12 Fourier Transform Yields complex functions for frequency

2

Overview

IntroductionTools for Sampling and Reconstruction

Fourier TransformConvolution (dt.: Faltung)Convolution TheoremFilteringFiltering

SamplingThe mathematical model

Reconstruction Sampling TheoremReconstruction in Practice

Eduard Gröller, Thomas Theußl, Peter Rautek 6

Sampling Theory

Relationship between signal and samplesView image data as signalsSignals are plotted as intensity vs. spatial domainSignals are represented as sum of sine wavesSignals are represented as sum of sine waves - frequency domain

Eduard Gröller, Thomas Theußl, Peter Rautek 7

Square Wave Approximation

Eduard Gröller, Thomas Theußl, Peter Rautek 8

Fourier Series

Eq1:

Eq2:

[ ]∑∞

=

−+=1

0 )cos(2

)f(n

nn xnAax ϕω

[ ]∑∞

++= 0 )sin()cos(2

)f( nn xnbxnaax ωω

Eq3:

Euler’s identity: Eduard Gröller, Thomas Theußl, Peter Rautek 9

xixeix sincos +=

=12 n

[ ]∑∞

−∞=

=n

xinnecx ω)f(

Fourier Transform

Link between spatial and frequency domain

∫∞

∞−

−= dxex iωxπ2)f()ωF(

Eduard Gröller, Thomas Theußl, Peter Rautek 10

∫∞

∞−

= ωdex xiωπ2)ωF()f(

Box & Tent

Eduard Gröller, Thomas Theußl, Peter Rautek 11

Page 3: Aliasing Sampling and Reconstruction - TU Wien · 3 Square Wave & Scanline Eduard Gröller, Thomas Theußl, Peter Rautek 12 Fourier Transform Yields complex functions for frequency

3

Square Wave & Scanline

Eduard Gröller, Thomas Theußl, Peter Rautek 12

Fourier Transform

Yields complex functions for frequency domainExtends to higher dimensionsComplex part is phase information - usually ignored in explanation and visual analysisignored in explanation and visual analysis

Alternative: Hartley transformWavelet transform

Eduard Gröller, Thomas Theußl, Peter Rautek 13

Discrete Fourier Transform

For discrete signals (i.e., sets of samples)

N2-1-N

0

N21-N

)xf(N1)ωF(

)ωF()f(

xj

xj

e

ex

ωπ

ωπ

⋅=

⋅=

∑=

Complexity for N samples: DFT O(N²)Fast FT (FFT): O(N log N)

Eduard Gröller, Thomas Theußl, Peter Rautek 14

0ωN =

Demo - Fast Fourier Transform- Different Frequencies

http://www.cs.brown.edu/exploratories/freeSoftware/repository/edu/brown/cs/exploratories/applets/fft1DApp/1d_fast_fourier_transform_java_browser.html

OverviewIntroductionTools for Sampling and Reconstruction

Fourier TransformConvolution (dt.: Faltung)Convolution TheoremFilteringFiltering

SamplingThe mathematical model

Reconstruction Sampling TheoremReconstruction in Practice

Eduard Gröller, Thomas Theußl, Peter Rautek 15

Convolution

Operation on two functionsResult: Sliding weighted average of a functionThe second function provides the weights

∫∞

dff )()())((

Eduard Gröller, Thomas Theußl, Peter Rautek 16

∫∞−

−=∗ τττ dgxfxgf )()())((

Demo - Copying (Dirac Pulse)- Averaging (Box Filter)

http://www.cs.brown.edu/exploratories/freeSoftware/repository/edu/brown/cs/exploratories/applets/convolution/convolution_java_browser.html

Convolution - Examples

Eduard Gröller, Thomas Theußl, Peter Rautek 17

Page 4: Aliasing Sampling and Reconstruction - TU Wien · 3 Square Wave & Scanline Eduard Gröller, Thomas Theußl, Peter Rautek 12 Fourier Transform Yields complex functions for frequency

4

Convolution Theorem

The spectrum of the convolution of two functions is equivalent to the product of the transforms of both input signals, and vice versa.

Eduard Gröller, Thomas Theußl, Peter Rautek 18

2121

2121

ffFFFFff

≡∗≡∗

Example - Low-Pass

Low-pass filtering performed on Mandrill scanline

Spatial domain: convolution with sincfunctionF d i t ff f hi hFrequency domain: cutoff of high frequencies - multiplication with box filter

Sinc function corresponds to box function and vice versa!

Eduard Gröller, Thomas Theußl, Peter Rautek 19

Low-Pass in Spatial Domain 1

Eduard Gröller, Thomas Theußl, Peter Rautek 20

Low-Pass in Spatial Domain 2

Eduard Gröller, Thomas Theußl, Peter Rautek 21

OverviewIntroductionTools for Sampling and Reconstruction

Fourier TransformConvolution (dt.: Faltung)Convolution TheoremFilteringFiltering

SamplingThe mathematical model

Reconstruction Sampling TheoremReconstruction in Practice

Eduard Gröller, Thomas Theußl, Peter Rautek 22

Sampling

The process of sampling is a multiplication of the signal with a comb function

)(comb)()( T xxfxfs ⋅=

The frequency response is convolved with a transformed comb function.

Eduard Gröller, Thomas Theußl, Peter Rautek 23

)(comb)()( T1 ωωω ∗= FFs

Page 5: Aliasing Sampling and Reconstruction - TU Wien · 3 Square Wave & Scanline Eduard Gröller, Thomas Theußl, Peter Rautek 12 Fourier Transform Yields complex functions for frequency

5

FT of Base Functions

Comb function: ω)(comb)(comb T1T ⇔x

Eduard Gröller, Thomas Theußl, Peter Rautek 24

Overview

IntroductionTools for Sampling and Reconstruction

Fourier TransformConvolution (dt.: Faltung)Convolution TheoremFilteringFiltering

SamplingThe mathematical model

Reconstruction Sampling TheoremReconstruction in Practice

Eduard Gröller, Thomas Theußl, Peter Rautek 25

Reconstruction

Recovering the original functionfrom a set of samples

Sampling theoremId l t tiIdeal reconstruction

Sinc functionReconstruction in practice

Eduard Gröller, Thomas Theußl, Peter Rautek 26

Definitions

A function is called band-limited if it contains no frequencies outside the interval [-u,u]. u is called the bandwidth of the function

The Nyquist frequency of a function is twice its b d idth i 2bandwidth, i.e. w = 2u

Eduard Gröller, Thomas Theußl, Peter Rautek 27

Sampling Theorem

A function f(x) that isband-limited andsampled above the Nyquist frequency

is completely determined by its samplesis completely determined by its samples.

Eduard Gröller, Thomas Theußl, Peter Rautek 28

Sampling at Nyquist Frequency

Eduard Gröller, Thomas Theußl, Peter Rautek 29

Page 6: Aliasing Sampling and Reconstruction - TU Wien · 3 Square Wave & Scanline Eduard Gröller, Thomas Theußl, Peter Rautek 12 Fourier Transform Yields complex functions for frequency

6

Sampling Below Nyquist Frequency

Eduard Gröller, Thomas Theußl, Peter Rautek 30

Demo - Under sampling- Nyquist Frequency

http://www.cs.brown.edu/exploratories/freeSoftware/repository/edu/brown/cs/exploratories/applets/nyquist/nyquist_limit_java_browser.html

Ideal Reconstruction

Replicas in frequency domain must not overlapMultiplying the frequency response with a box filter of the width of the original bandwidth restores originalgAmounts to convolution with Sinc function

Eduard Gröller, Thomas Theußl, Peter Rautek 31

Sinc Function

Infinite in extentIdeal reconstruction filterFT of box function

0sin⎧ if

Eduard Gröller, Thomas Theußl, Peter Rautek 32

00

1)sinc( πx

x sin

=≠

⎩⎨⎧

=xx

ifif

Sinc & Truncated Sinc

Eduard Gröller, Thomas Theußl, Peter Rautek 33

Reconstruction: Examples

Sampling and reconstruction of the Mandrill image scanline signal

with adequate sampling ratewith inadequate sampling ratedemonstration of band-limiting

With Sinc and tent reconstruction kernels

Eduard Gröller, Thomas Theußl, Peter Rautek 34

Adequate Sampling Rate

Eduard Gröller, Thomas Theußl, Peter Rautek 35

Page 7: Aliasing Sampling and Reconstruction - TU Wien · 3 Square Wave & Scanline Eduard Gröller, Thomas Theußl, Peter Rautek 12 Fourier Transform Yields complex functions for frequency

7

Adequate Sampling Rate

Eduard Gröller, Thomas Theußl, Peter Rautek 36

Inadequate Sampling Rate

Eduard Gröller, Thomas Theußl, Peter Rautek 37

Inadequate Sampling Rate

Eduard Gröller, Thomas Theußl, Peter Rautek 38

Band-Limiting a Signal

Eduard Gröller, Thomas Theußl, Peter Rautek 39

Band-Limiting a Signal

Eduard Gröller, Thomas Theußl, Peter Rautek 40

Reconstruction in Practice

Problem: which reconstruction kernel should be used?

Genuine Sinc function unusable in practiceTruncated Sinc often sub-optimalTruncated Sinc often sub-optimal

Various approximations exist; none is optimal for all purposes

Eduard Gröller, Thomas Theußl, Peter Rautek 41

Page 8: Aliasing Sampling and Reconstruction - TU Wien · 3 Square Wave & Scanline Eduard Gröller, Thomas Theußl, Peter Rautek 12 Fourier Transform Yields complex functions for frequency

8

Tasks of Reconstruction Filters

Remove the extraneous replicas of the frequency responseRetain the original undistorted frequency response

Eduard Gröller, Thomas Theußl, Peter Rautek 42

Used Reconstruction Filters

Nearest neighbourLinear interpolationSymmetric cubic filtersWindowed SincM hi ti t d f t ti th SiMore sophisticated ways of truncating the Sincfunction

Eduard Gröller, Thomas Theußl, Peter Rautek 43

Box & Tent Responses

Eduard Gröller, Thomas Theußl, Peter Rautek 44

Windowed Sinc Responses

Eduard Gröller, Thomas Theußl, Peter Rautek 45

Sampling & Reconstruction Errors

Aliasing: due to overlap of original frequency response with replicas - information lossTruncation Error: due to use of a finite reconstruction filter instead of the infinite SincfilterNon-Sinc error: due to use of a reconstruction filter that has a shape different from the Sincfilter

Eduard Gröller, Thomas Theußl, Peter Rautek 46

Interpolation - Zero Insertion

Operates on series of n samplesTakes advantage of DFT properties

Algorithm:P f DFT iPerform DFT on seriesAppend zeros to the sequencePerform the inverse DFT

Eduard Gröller, Thomas Theußl, Peter Rautek 47

Page 9: Aliasing Sampling and Reconstruction - TU Wien · 3 Square Wave & Scanline Eduard Gröller, Thomas Theußl, Peter Rautek 12 Fourier Transform Yields complex functions for frequency

9

Zero Insertion - Properties

Preserves frequency spectrumOriginal signal has to be sampled above Nyquist frequencyValues can only be interpolated at evenly spaced locationsspaced locationsThe whole series must be accessible, and it is always completely processed

Eduard Gröller, Thomas Theußl, Peter Rautek 48

Zero Insertion - Original Series

Eduard Gröller, Thomas Theußl, Peter Rautek 49

Zero Insertion - Interpolation

Eduard Gröller, Thomas Theußl, Peter Rautek 50

ConclusionSampling

Going from continuous to discrete signalMathematically modeled with a multiplication with comb functionSampling theorem: How many samples are needed

Reconstruction Sinc is the ideal filter but not practicableReconstruction in practiceAliasing

Eduard Gröller, Thomas Theußl, Peter Rautek 51

Sampling and Reconstruction

References:Computer Graphics: Principles and Practice, 2nd Edition, Foley, vanDam, Feiner, Hughes, Addison-Wesley, 1990What we need around here is more aliasing, Jim Blinn, IEEE Computer Graphics and Applications January 1989IEEE Computer Graphics and Applications, January 1989Return of the Jaggy, Jim Blinn, IEEE Computer Graphics and Applications, March 1989Demo Applets, Brown University, Rhode Island, USAhttp://www.cs.brown.edu/exploratories/freeSoftware/home.html

Eduard Gröller, Thomas Theußl, Peter Rautek 52

Questions

Eduard Gröller, Thomas Theußl, Peter Rautek 53