![Page 1: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/1.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Sampling Theorem & Antialiasing
April 15, 2003
![Page 2: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/2.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Today’s Short Film
NVIDIA Demo
![Page 3: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/3.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Part I: Sampling Theorem
![Page 4: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/4.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Example of Aliasing in Computer Graphics
![Page 5: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/5.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Examples of Aliasing in 1D
• See Figure 14.2 (p.394) of Watt’s book for other examples.
![Page 6: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/6.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Sampling
• 1D Signal: x f(x) becomes i f(i)
• 2D Image: x, y f(x, y)– For grayscale image, f(x, y) is the intensity
of pixel at (x, y).
![Page 7: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/7.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Reconstruction
• If the samples are “dense” enough, then we can recover the original signal.
• Question is: How dense is enough?
![Page 8: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/8.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
An Intuition – Using a Single Frequency
• It’s easy to figure out for a sin wave.
• What about any signal (usually a mixture of multiple frequencies)?
• Enter Fourier Transform…
![Page 9: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/9.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Fourier Transform
• Can we separate signal into a set of signals of single frequencies?
dxexfF xj
)()( sincos je xj
t
![Page 10: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/10.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Convolution
• To start with, image that f(x) is nonzero only in the range of [-a, a].– Then we only need to consider g(x) in the
range of [x-a, x+a]
• Multiplication in spatial domain results in convolution in frequency domain (and vice versa).
xdxxgxfxgxfxh )()()()()(
![Page 11: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/11.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Sampling
• Spatial domain: multiply with a pulse train.
• Frequency domain: convolution.
![Page 12: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/12.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Reconstruction
• Frequency domain:
• Spatial domain: convolve with Sinc function
![Page 13: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/13.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Reconstruction Kernel
• For perfect reconstruction, we need to convolve with the sinc function.– It’s the Fourier transform of the box
function.– It has infinite “support”
• May be approximated by Gaussian, cubic, or even triangle “tent” function.
![Page 14: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/14.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Nyquist Limit
• Nyquist Limit = 2 * max_frequency
• Undersampling: sampling below the Nyquist Limit.
![Page 15: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/15.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
An Exercise
• You have an online photo albums, and you want to show an index page using smaller versions of photos.
– Original size is 1600x1200– Index photo: 200x150 (1/8 of original)
• How do you create the index photos?
![Page 16: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/16.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Basis Functions
• An example:X=[x1, x2, …, xn]
U=[u1, u2, …, un]
V=[v1, v2, …, vn]
Let X = a*U + b*V, how to find a and b?
• If U and V are orthogonal, then a and b are the projection of X onto U and V.
![Page 17: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/17.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Compared to Fourier Transform
• Consider a continuous signal as a infinite-dimensional vector
[ f(), f(2), f(3),….. ]
• Consider each frequency a basis, then F() is the projection of f(x) onto that basis.
dxexfF xj
)()(
t
![Page 18: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/18.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
An Intuition for Convolution
• Does it make sense to you that multiplication in one domain becomes convolution in the other domain?
• Look at this example:
• What are the coefficients of P1*P2?2
12
22
322
11
12
13
11
)(
)(
dxcxbxaxP
dxcxbxaxP
![Page 19: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/19.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Convolution and Splatting
• Let f(x) be the reconstruction kernel, g(x) is the source, h(x) the target. We are only interested in g(a), g(2a)… and h(b), h(2b)…
• Two way to evaluate h(b), h(2b), …h(nb)– Use the above equation directly. (Loop over h(b),
h(2b), …)– Or we can “splat” g(x)! (Loop over g(a), g(2a), …)
xdxxgxfxgxfxh )()()()()(
![Page 20: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/20.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
g(x)
h(x)
f(x)
?
![Page 21: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/21.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Part II: Antialiasing
![Page 22: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/22.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Changes within a Pixel
• A lot can change within a pixel:– Shading– Edge– Texture
• Point sampling at the center often produces undesirable result.
![Page 23: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/23.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Pixel Coverage
• What should be the pixel colors for these?
• Can we simply use the covered areas of blue and white? (Hint: convolve with box filter.)
• Do we have enough data to compute the coverage?
![Page 24: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/24.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Antialiasing
• Consider a ray tracer. Is it often impossible to find the partial coverage of an edge.
• Each ray is a point sample.
• We may use many samples for each pixel slower performance.
![Page 25: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/25.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Antialiasing – Uniform Sampling
• Also called supersampling
• Wasteful if not much changes within a pixel.
![Page 26: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/26.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Filtering
• How do we reduce NxN supersamples into a pixel?– Average?– More weight near the center?
• Let’s resort to the sampling theorem.
![Page 27: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/27.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Reconstruction
• Frequency domain:
• Spatial domain:
![Page 28: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/28.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
A Few Observations
• In theory, a sample influences not only its pixel, but also every pixels in the image.
• What does it mean by removing high frequencies?
![Page 29: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/29.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Antialiasing – Adaptive Sampling
• Feasible in software, but difficult to implement in hardware.
• Increase samples only if necessary.
• But how do we know when is “necessary”?– Check the neighbors.
![Page 30: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/30.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
Antialiasing – Stochastic Sampling
• Keep the same number of samples per pixel.
• Replace the aliasing effects with noise that is easier to ignore.
![Page 31: CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003](https://reader030.vdocument.in/reader030/viewer/2022032704/56649d565503460f94a34c94/html5/thumbnails/31.jpg)
CS5520 Image-Based Rendering© Chun-Fa Chang, Spring 2003
EWA for Texture Mapping
• Paul Heckbert, “Survey of Texture Mapping” IEEE CG&A, Nov. 1986. (Figures)
• Green & Heckbert, “Creating Raster Omnimax Images from Multiple Perspective Views Using The Elliptical Weighted Average Filter” IEEE CG&A, 6(6), pp. 21-27, June 1986.