Sampling, Aliasing, - PowerPoint PPT Presentation

1 / 65
About This Presentation
Title:

Sampling, Aliasing,

Description:

In general, the Fourier transform is just a change of basis ... Ringing artifacts if prefiltering or supports are not perfect. MIT EECS 6.837 ... – PowerPoint PPT presentation

Number of Views:201
Avg rating:3.0/5.0
Slides: 66
Provided by: coursesC1
Category:

less

Transcript and Presenter's Notes

Title: Sampling, Aliasing,


1
Sampling, Aliasing, Mipmaps
2
Assignment 5
  • Extend your ray tracer
  • Phong shading
  • Shadows, reflection
  • Bounding sphere acceleration
  • Antialiasing
  • Solid textures
  • Plus required extra features lots of choice
  • More antialiasing, texture mapping, texture
    filtering, transparency, CSG, blobby objects,
    quaternion Julia fractals, more shading, spectral
    rendering, global illumination, OpenGL preview,
    mirages, relativity, multithreading, spatial
    acceleration data structures, image
    post-processing
  • You can propose your own (but ask us)

3
Assignment 5
  • Start early
  • We mean it, even more that for assignment 4
  • You need assignment 4
  • Some assignment 4 bugs will come and bite you!
  • If you implement features that were missing from
    your assignment 4, you will get half of those
    points.
  • Transformation ortho camera are the most
    orthogonal features
  • You are required to tell us which extension you
    will implement by Tuesday

4
Questions?
5
Examples of Aliasing
6
What is a Pixel?
  • A pixel is not
  • a box
  • a disk
  • a teeny tiny little light
  • A pixel looks different ondifferent display
    devices
  • A pixel is a sample
  • it has no dimension
  • it occupies no area
  • it cannot be seen
  • it has a coordinate
  • it has a value

7
Philosophical perspective
  • The physical world is continuous, inside the
    computer things need to be discrete
  • Lots of computer graphics is about translating
    continuous problems into discrete solutions
  • e.g. ODEs for physically-based animation, global
    illumination, meshes to represent smooth
    surfaces, rasterization, antialiasing
  • Careful mathematical understanding helps do the
    right thing

8
More on Samples
  • In signal processing, the process of mapping a
    continuous function to a discrete one is called
    sampling
  • The process of mapping a continuous variable to a
    discrete one is called quantization
  • Recall how gamma helped quantization
  • To represent or render an image using a computer,
    we must both sample and quantize
  • Today we focus on the effects of sampling and how
    to fight them

discretevalue
discrete position
9
Sampling reconstruction
  • The visual array of light is a continuous
    function
  • 1/ we sample it
  • with a digital camera, or with our ray tracer
  • This gives us a finite set of numbers, not
    really something we can see
  • We are now inside the discrete computer world
  • 2/ we need to get this back to the physical
    world we reconstruct a continuous function
  • for example, the point spread of a pixel on a CRT
    or LCD
  • Both steps can create problems
  • But well focus on the first one (were not
    display manufacturers)

10
Questions?
11
Examples of Aliasing
12
Examples of Aliasing
13
Examples of Aliasing
  • Texture Errors

point sampling
14
Sampling Density
  • If were lucky, sampling density is enough

Input
Reconstructed
15
Sampling Density
  • If we insufficiently sample the signal, it may be
    mistaken for something simpler during
    reconstruction (that's aliasing!)

16
Discussion
  • Two types of aliasing
  • Edges
  • Repetitive textures
  • More tricky
  • Harder to solve right
  • Motivates fun mathematics

17
Solution?
  • How do we avoid that high-frequency patterns mess
    up our image?
  • We blur!
  • In the case of audio, people first include an
    analog low-pass filter before sampling
  • For ray tracing compute at higher resolution,
    blur, resample at lower resolution
  • For textures, we can also blur the texture image
    before doing the lookup

18
Re-hashing
  • Your intuitive solution is to compute multiple
    color values per pixel and average them
  • A better interpretation of the same idea is that
  • You first create a higher resolution image
  • You blur it (average)
  • You resample it at a lower resolution

19
Questions?
20
Blurring convolution
Convolutionsign
Input
Kernel
21
Blurring convolution
Convolutionsign
Input
Kernel
Same shape, just reduced contrast!!!
This is an eigenvector (output is the input
multiplied by a constant)
22
Motivation for Fourier analysis
  • Sampling/reconstruction is a linear process
  • The sampling grid is a periodic structure
  • Fourier is pretty good at handling that
  • We saw that a sine wave has serious problems with
    sampling
  • The solution is about blurring
  • We have seen that sine wave are simple wrt blur
  • In general, the Fourier transform is just a
    change of basis
  • In that basis, aliasing blurring are easier to
    understand
  • become diagonal

23
Remember Fourier Analysis?
  • All periodic signals can be represented as a
    summation of sinusoidal waves.

Images from http//axion.physics.ubc.ca/341-02/fo
urier/fourier.html
24
Other motivation for sine waves
  • 1/ we have seen that sine waves have aliasing
    problems
  • 2/ Blurring sine waves is simple
  • You get the same sine wave, just scaled down
  • The sine functions are the eigenvectors of the
    convolution operator
  • Aliasing/antialiasing is all about blurring the
    stuff that cannot be resolved
  • Makes Fourier bases appropriate

25
Remember Fourier Analysis?
  • Every periodic signal in the spatial domain has a
    dual in the frequency domain (change of basis)
  • This particular signal is band-limited, meaning
    it has no frequencies above some threshold

frequency domain
spatial domain
26
Remember Fourier Analysis?
  • We can transform from one domain to the other
    using the Fourier Transform.
  • Pretty much a bunch of dot products over functions

spatial domain
frequency domain
Fourier Transform
Inverse Fourier Transform
27
Remember Convolution?
  • Some operations that are difficult to compute in
    the spatial domain can be simplified by
    transforming to its dual representation in the
    frequency domain.
  • For example, convolution in the spatial domain is
    the same as multiplication in the frequency
    domain.
  • Because sine waves are eigen functions
  • And, convolution in the frequency domain is the
    same as multiplication in the spatial domain

28
Sampling in the Frequency Domain
Fourier Transform
originalsignal
Fourier Transform
samplinggrid
(multiplication)
(convolution)
Fourier Transform
sampledsignal
29
Reconstruction
  • If we can extract a copy of the original signal
    from the frequency domain of the sampled signal,
    we can reconstruct the original signal!
  • But there may be overlap between the copies.

30
Guaranteeing Proper Reconstruction
  • Separate by removing high frequencies from the
    original signal (low pass pre-filtering)
  • Separate by increasing the sampling density
  • If we can't separate the copies, we will have
    overlapping frequency spectrum during
    reconstruction ? aliasing.

31
Sampling Theorem
  • When sampling a signal at discrete intervals, the
    sampling frequency must be greater than twice the
    highest frequency of the input signal in order to
    be able to reconstruct the original perfectly
    from the sampled version (Shannon, Nyquist,
    Whittaker, Kotelnikov)

32
Questions?
33
Filters (a.k.a convolution kernel)
  • Weighting function or aconvolution kernel
  • Area of influence often bigger than "pixel"
  • Sum of weights 1
  • Each sample contributes the same total to image
  • Constant brightness as object moves across the
    screen.
  • No negative weights/colors (optional)

34
Filters
  • Filters are used to
  • reconstruct a continuous signal from a sampled
    signal (reconstruction filters)
  • band-limit continuous signals to avoid aliasing
    during sampling (low-pass filters)
  • Desired frequency domain properties are the same
    for both types of filters
  • Often, the same filters are used as
    reconstruction and low-pass filters

35
Pre-Filtering
  • Filter continuous primitives
  • Treat a pixel as an area
  • Compute weighted amount of object overlap
  • What weighting function should we use?

36
Post-Filtering
  • Filter samples
  • Compute the weighted average of many samples
  • Regular or jittered sampling (better)

37
The Ideal Filter
  • Unfortunately it has infinite spatial extent
  • Every sample contributes to every interpolated
    point
  • Expensive/impossible to compute

spatial
frequency
38
Problems with Practical Filters
  • Many visible artifacts in re-sampled images are
    caused by poor reconstruction filters
  • Excessive pass-band attenuation results in blurry
    images
  • Excessive high-frequency leakage causes
    "ringing" and can accentuate the sampling grid
    (anisotropy)

frequency
39
Gaussian Filter
  • This is what a CRTdoes for free!

spatial
frequency
40
Box Filter / Nearest Neighbor
  • Pretending pixelsare little squares.

spatial
frequency
41
Tent Filter / Bi-Linear Interpolation
  • Simple to implement
  • Reasonably smooth

spatial
frequency
42
Bi-Cubic Interpolation
  • Begins to approximate the ideal spatial filter,
    the sinc function

spatial
frequency
43
Why is the Box filter bad?
  • (Why is it bad to think of pixels as squares)

Down-sampled with a 5x5 box filter (uniform
weights)
Down-sampled with a 5x5 Gaussian
filter(non-uniform weights)
Original high-resolution image
notice the ugly horizontal banding
44
Questions?
45
Recap Ideal sampling/reconstruction
  • Pre-filter with a perfect low-pass filter
  • Box in frequency
  • Sinc in time
  • Sample at Nyquist limit
  • Twice the frequency cutoff
  • Reconstruct with perfect filter
  • Box in frequency, sinc in time
  • And everything is great!

46
Difficulties with perfect sampling
  • Hard to prefilter
  • Perfect filter has infinite support
  • Fourier analysis assumes infinite signal and
    complete knowledge
  • Not enough focus on local effects
  • And negative lobes
  • Emphasizes the two problems above
  • Negative light is bad
  • Ringing artifacts if prefiltering or supports are
    not perfect

47
At the end of the day
  • Fourier analysis is great to understand aliasing
  • But practical problems kick in
  • As a result there is no perfect solution
  • Compromises between
  • Finite support
  • Avoid negative lobes
  • Avoid high-frequency leakage
  • Avoid low-frequency attenuation
  • Everyone has their favorite cookbook recipe
  • Gaussian, tent, Mitchell bicubic

48
The special case of edges
  • An edge is poorly captured by Fourier analysis
  • It is a local feature
  • It combines all frequencies (sinc)
  • Practical issues with edge aliasing lie more in
    the jaggies (tilted lines) than in actual
    spectrum replication

49
Anisotropy of the sampling grid
  • More diagonal bandwidth
  • E.g. less bandwidth in horizontal
  • A hexagonal grid would be better
  • Max anisotropy
  • But less practical

50
Anisotropy of the sampling grid
  • More vertical and horizontal bandwidth
  • A hexagonal grid would be better
  • But less practical
  • Practical effect vertical and horizontal
    direction show when doing bicubic upsampling

Low-res image
Bicubic upsampling
51
Philosophy about mathematics
  • Mathematics are great tools to model (i.e.
    describe) your problems
  • They afford incredible power, formalism,
    generalization
  • However it is equally important to understand the
    practical problem and how much the mathematical
    model fits

52
Questions?
53
Supersampling in graphics
  • Pre-filtering is hard
  • Requires analytical visibility
  • Then difficult to integrate analytically with
    filter
  • Possible for lines, or if visibility is ignored
  • usually, fall back to supersampling

54
Uniform supersampling
  • Compute image at resolution kwidth, kheight
  • Downsample using low-pass filter (e.g. Gaussian,
    sinc, bicubic)

55
Uniform supersampling
  • Advantage
  • The first (super)sampling captures more high
    frequencies that are not aliased
  • Downsampling can use a good filter
  • Issues
  • Frequencies above the (super)sampling limit are
    still aliased
  • Works well for edges, since spectrum replication
    is less an issue
  • Not as well for repetitive textures
  • But mipmapping can help

56
Questions?
57
Uniform supersampling
  • Problem supersampling only pushes the problem
    further The signal is still not bandlimited
  • Aliasing happens

58
Jittering
  • Uniform sample random perturbation
  • Sampling is now non-uniform
  • Signal processing gets more complex
  • In practice, adds noise to image
  • But noise is better than aliasing Moiré patterns

59
Jittered supersampling
  • Regular, Jittered Supersampling

60
Jittering
  • Displaced by a vector a fraction of the size of
    the subpixel distance
  • Low-frequency Moire (aliasing) pattern replaced
    by noise
  • Extremely effective
  • Patented by Pixar!
  • When jittering amount is 1, equivalent to
    stratified sampling (cf. later)

61
Adaptive supersampling
  • Use more sub-pixel samples around edges

62
Adaptive supersampling
  • Use more sub-pixel samples around edges
  • Compute color at small number of sample
  • If their variance is high
  • Compute larger number of samples

63
Adaptive supersampling
  • Use more sub-pixel samples around edges
  • Compute color at small number of sample
  • If variance with neighbor pixels is high
  • Compute larger number of samples

64
Problem with non-uniform distribution
  • Reconstruction can be complicated

80 of the samples are black Yet the pixel should
be light grey
65
Problem with non-uniform distribution
  • Reconstruction can be complicated
  • Solution do a multi-level reconstruction
  • Reconstruct uniform sub-pixels
  • Filter those uniform sub-pixels
Write a Comment
User Comments (0)
About PowerShow.com