sampling theory 101

Upload: lars-andersson

Post on 08-Apr-2018

241 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 Sampling Theory 101

    1/60

    Sampling Theory 101Oliver Kreylos

    [email protected]

    Center for Image Processing and Integrated Computing (CIPIC)

    Department of Computer Science

    University of California, Davis

    CIPIC Seminar 11/06/02 p.

  • 8/7/2019 Sampling Theory 101

    2/60

    Outline

    Things that typically go wrong

    Mathematical model of sampling

    How to do things better

    CIPIC Seminar 11/06/02 p.

  • 8/7/2019 Sampling Theory 101

    3/60

    Things That Typically Go Wrong

    CIPIC Seminar 11/06/02 p.

  • 8/7/2019 Sampling Theory 101

    4/60

    Where Does Sampling Occur?

    Almost all data we are dealing with is discrete

    Evaluation of sampled functions at arbitrarysites

    Volume rendering Isosurface extraction

    Ray tracing

    . . .

    CIPIC Seminar 11/06/02 p.

  • 8/7/2019 Sampling Theory 101

    5/60

    What Went Wrong Here?

    Typical ray tracing example:

    CIPIC Seminar 11/06/02 p.

  • 8/7/2019 Sampling Theory 101

    6/60

    Sampling and Reconstruction

    CIPIC Seminar 11/06/02 p.

  • 8/7/2019 Sampling Theory 101

    7/60

    Sampling and Reconstruction

    CIPIC Seminar 11/06/02 p.

  • 8/7/2019 Sampling Theory 101

    8/60

    Sampling and Reconstruction

    CIPIC Seminar 11/06/02 p.

  • 8/7/2019 Sampling Theory 101

    9/60

    Sampling and Reconstruction

    Undersampling?

    Sampling below Nyquist rate?

    Quick solution: Double sampling rate

    CIPIC Seminar 11/06/02 p.

  • 8/7/2019 Sampling Theory 101

    10/60

    Sampling and Reconstruction

    CIPIC Seminar 11/06/02 p.

  • 8/7/2019 Sampling Theory 101

    11/60

    Sampling and Reconstruction

    Things get better, but are still bad

    Isnt sampling above the Nyquist ratesupposed to solve all problems?

    CIPIC Seminar 11/06/02 p.

  • 8/7/2019 Sampling Theory 101

    12/60

    Sampling Theory

    To understand what went wrong on the last slide,

    we need a mathematical model of sampling.

    CIPIC Seminar 11/06/02 p.

  • 8/7/2019 Sampling Theory 101

    13/60

    Mathematical Model of Sampling

    CIPIC Seminar 11/06/02 p.

  • 8/7/2019 Sampling Theory 101

    14/60

    Choice of Domain

    Process of sampling and reconstruction is

    best understood in frequency domain Use Fourier transform to switch between time

    and frequency domains

    Function in time domain: signal

    Function in frequency domain: spectrum

    CIPIC Seminar 11/06/02 p.

  • 8/7/2019 Sampling Theory 101

    15/60

    Fourier Transform I

    Many functions f:R R can be written as

    sums of sine waves

    f(x) =

    a sin(x + )

    = 2 frequency is angular velocity,

    a is amplitude, and

    is phase shift

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    16/60

    Fourier Transform II

    Moving to complex numbers simplifies

    notation:

    cos(x) + i sin(x) = eix

    (Euler identity) One complex coefficient ce

    ix encodes bothamplitude and phase shift

    Moving to integral enlarges class ofrepresentable functions

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    17/60

    Fourier Transform III

    Now, for almost all f:

    f(x) =

    F()eix d

    F() is the spectrum of f(x), and the aboveoperator is the inverse Fourier transform

    Its inverse, the Fourier transform, is

    F() =

    f(x)eix dx

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    18/60

    Some Signals and Their Spectra

    Single sine wave f(x) = sin(x):

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    19/60

    Some Signals and Their Spectra

    Sum of two sine waves

    f(x) = sin(x) + 0.5 sin(2x):

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    20/60

    Some Signals and Their Spectra

    Box function:

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    21/60

    Some Signals and Their Spectra

    Wider box function:

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    22/60

    Some Signals and Their Spectra

    Triangle function:

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    23/60

    Some Signals and Their Spectra

    Comb function:

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    24/60

    Some Signals and Their Spectra

    Wider comb function:

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    25/60

    Convolution I

    The convolution operator is a generalized

    formula to express weighted averaging of aninput signal f and a weight function or filterkernel g:

    (f g)(x) =

    f(t) g(x t) dt

    One important application of convolution isreconstructing sampled signals

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    26/60

    Convolution II

    (f g)(x0) = f(t) g(x0 t) dt

    x

    f

    x

    g

    x0x

    f

    x0

    x

    f

    x0

    x

    f

    x0

    x

    f*g

    x0

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    27/60

    Convolution III

    Linear interpolation can be interpreted as

    convolution:

    x

    f

    x

    g

    x

    f

    x

    f

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    28/60

    Function Reconstruction

    Constant interpolation:

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    29/60

    Function Reconstruction

    Linear interpolation:

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    30/60

    Function Reconstruction

    Catmull-Rom interpolation:

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    31/60

    Function Reconstruction

    Cubic B-spline approximation:

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    32/60

    The Convolution Theorem

    The Convolution Theorem relates convolution

    and Fourier transform:(f g) F G

    Convolutions can be computed by goingthrough the frequency domain:

    (f g) = IFT(FT(f) FT(g))

    CIPIC Seminar 11/06/02 p.1

  • 8/7/2019 Sampling Theory 101

    33/60

  • 8/7/2019 Sampling Theory 101

    34/60

    Sampling in Frequency Domain

    The spectrum of s is the convolution of F

    and C, the spectra of f and c C is a comb function with tap distance 2/d

    Sconsists of shifted copies of F, each 2/dapart

    CIPIC Seminar 11/06/02 p.2

  • 8/7/2019 Sampling Theory 101

    35/60

    Sampling Process - Time Domain

    CIPIC Seminar 11/06/02 p.2

  • 8/7/2019 Sampling Theory 101

    36/60

    Sampling Process - Frequency Domai

    CIPIC Seminar 11/06/02 p.2

  • 8/7/2019 Sampling Theory 101

    37/60

    Sampling in Frequency Domain

    If the sampling frequency is , the replicated

    copies of fs spectrum are apart If the highest-frequency component in f is f,fs spectrum covers the interval [f, f]

    If f /2, then the replicated spectraoverlap!

    This means, information is lost

    CIPIC Seminar 11/06/02 p.2

  • 8/7/2019 Sampling Theory 101

    38/60

    The Sampling Theorem

    If f is a frequency-limited function with

    maximum frequency f, then f must besampled with a sampling frequency largerthan 2f in order to be able to exactly

    reconstruct f from its samples. This theorem is sometimes called Shannons

    Theorem

    2f is sometimes called Nyquist rate

    CIPIC Seminar 11/06/02 p.2

  • 8/7/2019 Sampling Theory 101

    39/60

    Reconstruction

    The only difference between F and S is that S

    is made of shifted copies of F If those extra, higher-frequency, spectra could

    be removed from S, f would magically

    reappear Reconstructing f means low-pass-filtering s!

    CIPIC Seminar 11/06/02 p.2

  • 8/7/2019 Sampling Theory 101

    40/60

    Reconstruction Process - Frequency

    CIPIC Seminar 11/06/02 p.2

  • 8/7/2019 Sampling Theory 101

    41/60

    Reconstruction Process - Time Domai

    CIPIC Seminar 11/06/02 p.2

  • 8/7/2019 Sampling Theory 101

    42/60

    Reconstruction Problem

    Practical problem: The optimal reconstruction

    filter, the sinc function, has infinite support Evaluating it in the time domain involves

    computing a weighted average of infinitely

    many samples Practical reconstruction filters must have finite

    support

    But: A perfect low-pass filter with finitesupport does not exist!

    CIPIC Seminar 11/06/02 p.2

  • 8/7/2019 Sampling Theory 101

    43/60

    The Quest For Better Filters

    CIPIC Seminar 11/06/02 p.2

    C l U d Fil

  • 8/7/2019 Sampling Theory 101

    44/60

    Commonly Used Filters

    Constant filter:

    CIPIC Seminar 11/06/02 p.3

    C l U d Fil

  • 8/7/2019 Sampling Theory 101

    45/60

    Commonly Used Filters

    Linear filter:

    CIPIC Seminar 11/06/02 p.3

    C l U d Filt

  • 8/7/2019 Sampling Theory 101

    46/60

    Commonly Used Filters

    Catmull-Rom filter:

    CIPIC Seminar 11/06/02 p.3

  • 8/7/2019 Sampling Theory 101

    47/60

    S li Th Filt

  • 8/7/2019 Sampling Theory 101

    48/60

    Sampling Theory Filters

    Truncated sinc filter:

    CIPIC Seminar 11/06/02 p.3

    S li Th Filt

  • 8/7/2019 Sampling Theory 101

    49/60

    Sampling Theory Filters

    Lanczos filter:

    CIPIC Seminar 11/06/02 p.3

    Sampling Theory Filters

  • 8/7/2019 Sampling Theory 101

    50/60

    Sampling Theory Filters

    Full sinc filter:

    CIPIC Seminar 11/06/02 p.3

  • 8/7/2019 Sampling Theory 101

    51/60

    Sampling Theory Applications

    CIPIC Seminar 11/06/02 p.3

  • 8/7/2019 Sampling Theory 101

    52/60

    Function Resampling

  • 8/7/2019 Sampling Theory 101

    53/60

    Function Resampling

    When resampling a sampled function to adifferent grid (shifted and/or scaled), it isimportant to use a good reconstruction filter

    When downsampling a function, it is

    important to use a good low-pass filter to cutoff frequencies above half the new samplingfrequency

    CIPIC Seminar 11/06/02 p.3

    Volume Rendering

  • 8/7/2019 Sampling Theory 101

    54/60

    Volume Rendering

    Basic question: How many samples to takeper cell?

    d

    CIPIC Seminar 11/06/02 p.3

    Volume Rendering

  • 8/7/2019 Sampling Theory 101

    55/60

    Volume Rendering

    Basic question: How many samples to takeper cell?

    d

    Sampling theory says 1, but integrationalong ray might demand more

    CIPIC Seminar 11/06/02 p.3

    Ray Tracing

  • 8/7/2019 Sampling Theory 101

    56/60

    Ray Tracing

    In ray tracing, the function to be sampled istypically not frequency-limited

    Practical solution: Shoot multiple rays perpixel (oversampling) and sample down to

    image resolution Using a good low-pass filter is important

    CIPIC Seminar 11/06/02 p.3

    Ray Tracing

  • 8/7/2019 Sampling Theory 101

    57/60

    Ray Tracing

    CIPIC Seminar 11/06/02 p.3

  • 8/7/2019 Sampling Theory 101

    58/60

    Conclusions

    CIPIC Seminar 11/06/02 p.3

    Conclusions

  • 8/7/2019 Sampling Theory 101

    59/60

    Conclusions

    Knowing the mathematical background ofsampling and reconstruction helps tounderstand common problems and devisesolutions

    Ad-hoc solutions usually do not work well This stuff should be taught in class!

    CIPIC Seminar 11/06/02 p.3

  • 8/7/2019 Sampling Theory 101

    60/60

    The End

    CIPIC Seminar 11/06/02 p.3