Computer Graphics Sampling PowerPoint PPT Presentation

presentation player overlay
1 / 29
About This Presentation
Transcript and Presenter's Notes

Title: Computer Graphics Sampling


1
Computer Graphics- Sampling -
  • Marcus Magnor

2
Overview
  • Today
  • Signal Processing
  • Sampling
  • Next lecture
  • Anti-Aliasing

3
Motivation
4
The Digital Dilemma
  • Nature continuous signal (2D/3D/4D with time)
  • Defined at all points
  • Acquisition sampling
  • Rays, pixel/texel, spectral values, frames, ...
  • Representation discrete data
  • Discrete points, discretized values
  • Reconstruction interpolation
  • Mimic continuous signal
  • Impression natural
  • Hopefully similar to the original signal, no
    artefacts

, not
5
Sensors
  • Sampling of signals
  • Conversion of a continuous signal to discrete
    samples by integrating over the sensor field
  • Required by physical processes
  • Examples
  • Photo receptors in the retina
  • CCD cells
  • Virtual cameras in computer graphics
  • Inegration usually avoided
  • too expensive
  • Ray tracing mathematically ideal point samples
  • Origin of alias !

6
Aliasing
  • Ray tracing
  • Textured plane
  • Checkerboard period becomes smaller than two
    pixels
  • Nyquist limit
  • One ray for each pixel (say, at pixel center)
  • Hits textured plane at only one point, black or
    white by chance
  • (correct integrate over pixel pre-image texture
    mapping lecture)

7
Spatial Frequency
  • Frequency period length of some structure in an
    image
  • Unit 1/pixel
  • Range -0.50.5 (-??)
  • Lowest frequency
  • Image average
  • Highest frequency Nyquist
  • In nature light wavelength
  • In graphics image resolution

8
Nyquist Frequency
  • Highest (spatial) frequency that can be
    represented
  • Determined by image resolution (pixel size)

Spatial frequency lt Nyquist
Spatial frequency Nyquist 2 samples / period
Spatial frequency gt Nyquist
Spatial frequency gtgt Nyquist
9
Fourier Transformation
  • Any continuous function f(x) can be expressed as
    an integral over sine and cosine waves
  • f(x) ? a(?) sin(? x) b(?) cos(? x) d?
  • ? c(?) exp(-i ? x) d?
  • a(?) ? sin(? x) f(x) dx
  • b(?) ? cos(? x) f(x) dx
  • c(?) ? exp(i ? x) f(x) dx
  • Sine cosine orthonormal basis functions
  • a(?), b(?) weighting functions
  • c(?) (complex-valued) Fourier transform

10
Fourier Transformation
  • Any periodic, continuous function can be
    expressed as the sum of an (infinite) number of
    sine or cosine waves
  • f(x)?k ak sin(2?kx) bk cos(2?kx)
  • k frequency band
  • k0 mean value
  • k1 function period, lowest possible frequency
  • k1.5 ? not possible, periodic function f(x)
    f(x1)
  • kmax ? band limit, no higher frequency present
    in signal
  • ak,bk (real-valued) Fourier coefficients
  • Even function f(x)f(-x)
  • ak 0
  • Uneven function f(x) -f(-x)
  • bk 0

11
Fourier Synthesis Example
  • Periodic, uneven function square wave
  • f(x) 0.5 ? 0 lt (x mod 2?) lt ?
    -0.5 ? ? lt (x mod 2?) lt 2?
  • ak ? sin(kx) f(x) dx f(x)?k
    ak sin(kx)
  • a0 0
  • a1 1
  • a2 0
  • a3 1/3
  • a4 0
  • a5 1/5
  • a6 0
  • a7 1/7
  • a8 0
  • a9 1/9

12
Spectral Analysis
  • Fourier coefficients
  • ak 1/2? ? sin(2?kx) f(x) dx , bk 1/2? ?
    cos(2?kx) f(x) dx
  • Periodic function f(x)
  • integral over function period length (normalized
    to 1)
  • Even function ak 0
  • Uneven function bk 0
  • Decomposition of signal into different frequency
    bands
  • Representation of a function as weighted sum of
    sine and cosine functions
  • Equivalent representations of a periodic function
  • Spatial/temporal domain f(x)
  • Frequency domain F(k) ak , bk

13
Discrete Fourier Transform
  • Equally-spaced function samples
  • Function values known only at discrete points
  • Physical measurements
  • Pixel positions in an image !
  • Fourier Analysis
  • ak 1/ N ?i sin(2? k i / N) fi , bk 1/ N
    ?i cos(2? k i / N) fi
  • Sum over all measurement points N
  • k0,1,2, , ? Highest possible frequency ?
  • Nyquist frequency
  • Sampling rate Ni
  • 2 samples / period ? 0.5 cycles per pixel
  • k ? N / 2
  • Above Nyquist repetition, periodic fourier
    transform function

14
Spatial vs. Frequency Domain
  • Examples (pixel vs
  • cycles per pixel)
  • Sine wave with positive offset

  • Square wave
  • Scanline of animage

15
2D Fourier Transform
  • 2 separate 1D Fourier transformations along x-
    and y-direction
  • Discontinuities orthogonal direction in Fourier
    domain !

16
2D Fourier Transforms
17
Spatial vs. Frequency Domain
  • Important basis
    functions
  • Box ?? sinc
  • Wide box ? small sinc
  • Negative values
  • Infinite support
  • Triangle ?? sinc2
  • Gauss ?? Gauss

18
Spatial vs. Frequency Domain
  • Transform behavior
  • Example box function
  • Fourier transform sinc
  • Wide box narrow sinc
  • Narrow box wide sinc

19
Convolution
  • Two functions f, g
  • Shift one function against the other by x
  • Multiply function values
  • Integrate
  • overlapping region
  • Numerical convolutionExpensive operation
  • For each x integrate over non-zero domain

20
Convolution and Filtering
  • Technical Realisation
  • In image domain
  • Pixel mask with weights
  • OpenGL Convolution
  • Problems (e.g. sinc)
  • Large filter support
  • Large mask
  • A lot of computation
  • Negative weights
  • Negative light?

21
Convolution Theorem
  • convolution in image domain multiplication in
    Fourier domain
  • convolution in Fourier domain multiplication in
    image domain
  • Multiplication much cheaper than convolution !

22
Filtering
  • Low-pass filtering
  • Convolution with sinc inspatial domain, or
  • multiplication with box in frequency domain
  • High-pass filtering
  • Only high frequencies
  • Band-pass filtering
  • Only intermediate
    frequencies

Low-pass filtering in frequency domain
multiplication with box
23
Low-Pass Filtering
  • Blurring

24
High-Pass Filtering
  • Enhances discontinuities in image
  • Useful for edge detection

25
Sampling
  • Constant ?-Function
  • flash
  • Comb/Shah
    function

26
Sampling
  • Constant ?-Function
  • Duality
  • And vice versa
  • Comb function
  • Duality The dual of a comb function is again a
    comb function
  • Inverse wave length, amplitude scales with
    inverse wave length

27
Sampling
  • Continuous function
  • Band-limited Fourier transform
  • Sampled at discrete points
  • Multiplication with Comb function in space domain
  • Corresponds to convolution in Fourier domain
  • Frequency bands overlap ?
  • No good
  • Yes bad, aliasing

28
Reconstruction
  • Only original frequency band desired
  • Filtering
  • In Fourier domain multiplication with windowing
    function around origin
  • In Space domain convolution with Fourier
    transform of windowing function
  • Optimal filtering function
  • Hat function in Fourier domain
  • Corresponds to sinc in space domain
  • Unlimited region of support
  • In space domain only filter approximations
    possible

29
Wrap-Up
  • Fourier transformation
  • Equivalent representation of transformed signal
  • Spectral analysis shows signals frequency
    components
  • Convolution
  • Filtering
  • Sampling
  • Multiplication with comb function
  • Only at discrete points no integration over
    signal
  • Frequency spectrum replicated
  • Replication distance sampling rate
Write a Comment
User Comments (0)
About PowerShow.com