MIT EECS 6.837 Sampling and Monte-Carlo Integration.

Slides:



Advertisements
Similar presentations
Sampling, Aliasing.
Advertisements

Sampling and Reconstruction
David Luebke 1 4/28/2015 Aliasing & Antialiasing.
David Luebke1/19/99 CS 551/651: Antialiasing David Luebke
Ted Adelson’s checkerboard illusion. Motion illusion, rotating snakes.
MIT EECS 6.837, Durand and Cutler Sampling, Aliasing, & Mipmaps.
CS 551 / CS 645 Antialiasing. What is a pixel? A pixel is not… –A box –A disk –A teeny tiny little light A pixel is a point –It has no dimension –It occupies.
Aliasing & Antialiasing
Monte Carlo Integration Robert Lin April 20, 2004.
Advanced Computer Graphics (Fall 2010) CS 283, Lecture 3: Sampling and Reconstruction Ravi Ramamoorthi Some slides.
Sampling, Aliasing, & Mipmaps
Convolution, Edge Detection, Sampling : Computational Photography Alexei Efros, CMU, Fall 2006 Some slides from Steve Seitz.
CSCE 641 Computer Graphics: Image Sampling and Reconstruction Jinxiang Chai.
General Functions A non-periodic function can be represented as a sum of sin’s and cos’s of (possibly) all frequencies: F(  ) is the spectrum of the function.
CSCE 641 Computer Graphics: Image Sampling and Reconstruction Jinxiang Chai.
Image Sampling Moire patterns
Advanced Computer Graphics (Spring 2006) COMS 4162, Lecture 3: Sampling and Reconstruction Ravi Ramamoorthi
CSCE 641 Computer Graphics: Fourier Transform Jinxiang Chai.
CS5520 Image-Based Rendering © Chun-Fa Chang, Spring 2003 Sampling Theorem & Antialiasing April 15, 2003.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Sampling Week 7, Fri 17 Oct 2003 p1 demos sampling.
CPSC 641 Computer Graphics: Fourier Transform Jinxiang Chai.
Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 3: Sampling and Reconstruction Ravi Ramamoorthi
Computational Photography: Fourier Transform Jinxiang Chai.
Review of Probability and Random Processes
CIS 681 Distributed Ray Tracing. CIS 681 Anti-Aliasing Graphics as signal processing –Scene description: continuous signal –Sample –digital representation.
Image Sampling Moire patterns -
Lecture II-2: Probability Review
CSC418 Computer Graphics n Aliasing n Texture mapping.
Sampling and Antialiasing CMSC 491/635. Abstract Vector Spaces Addition –C = A + B = B + A –(A + B) + C = A + (B + C) –given A, B, A + X = B for only.
Advanced Computer Graphics CSE 190 [Spring 2015], Lecture 3 Ravi Ramamoorthi
Filtering theory: Battling Aliasing with Antialiasing Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
CS 431/636 Advanced Rendering Techniques
© Chun-Fa Chang Sampling Theorem & Antialiasing. © Chun-Fa Chang Motivations “ My ray traced images have a lot more pixels than the TV screen. Why do.
Antialiasing CptS 548 Advanced Computer Graphics John C. Hart.
1 CE 530 Molecular Simulation Lecture 7 David A. Kofke Department of Chemical Engineering SUNY Buffalo
David Luebke 1 9/4/2015 CS 551/651: Advanced Computer Graphics Antialiasing Continued: Prefiltering and Supersampling.
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping.
Applications of Image Filters Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 02/04/10.
Filtering Robert Lin April 29, Outline Why filter? Filtering for Graphics Sampling and Reconstruction Convolution The Fourier Transform Overview.
CS 450: COMPUTER GRAPHICS ANTIALIASING SPRING 2015 DR. MICHAEL J. REALE.
02/10/03© 2003 University of Wisconsin Last Time Participating Media Assignment 2 –A solution program now exists, so you can preview what your solution.
Week 6 - Wednesday.  What did we talk about last time?  Light  Material  Sensors.
09/19/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Dithering.
Image Processing Basics. What are images? An image is a 2-d rectilinear array of pixels.
CMSC 635 Sampling and Antialiasing. Aliasing in images.
Duy & Piotr. How to reconstruct a high quality image with the least amount of samples per pixel the least amount of resources And preserving the image.
MIT EECS Sampling, Aliasing, & Mipmaps. MIT EECS Last Time? Global illumination “physically accurate light transport” The rendering equation.
Computer simulation Sep. 9, QUIZ 2 Determine whether the following experiments have discrete or continuous out comes A fair die is tossed and the.
Sampling Pixel is an area!! – Square, Rectangular, or Circular? How do we approximate the area? – Why bother? Color of one pixel Image Plane Areas represented.
Probability and Distributions. Deterministic vs. Random Processes In deterministic processes, the outcome can be predicted exactly in advance Eg. Force.
Sampling Theorem & Antialiasing
(c) 2002 University of Wisconsin, CS 559
1 Review of Probability and Random Processes. 2 Importance of Random Processes Random variables and processes talk about quantities and signals which.
1 Dr. Scott Schaefer Antialiasing. 2/70 What is aliasing?
David Luebke 3/17/2016 Advanced Computer Graphics Antialiasing David Luebke
CIS 681 Distributed Ray Tracing. CIS 681 Anti-Aliasing Graphics as signal processing –Scene description: continuous signal –Sample –digital representation.
University of Texas at Austin CS384G - Computer Graphics Fall 2008 Don Fussell Sampling and Reconstruction.
Antialiasing. What is alias? Alias - A false signal in telecommunication links from beats between signal frequency and sampling frequency (from dictionary.com)
Advanced Computer Graphics
Distributed Ray Tracing
Sampling Theorem & Antialiasing
Sampling and Antialiasing
Antialiasing Dr. Scott Schaefer.
General Functions A non-periodic function can be represented as a sum of sin’s and cos’s of (possibly) all frequencies: F() is the spectrum of the function.
Sampling Theorem told us …
Joshua Barczak CMSC435 UMBC
Sampling and Reconstruction
Distributed Ray Tracing
CSC418 Computer Graphics Aliasing Texture mapping.
Distributed Ray Tracing
Presentation transcript:

MIT EECS Sampling and Monte-Carlo Integration

MIT EECS Sampling and Monte-Carlo Integration

MIT EECS Last Time Pixels are samples Sampling theorem Convolution & multiplication Aliasing: spectrum replication Ideal filter –And its problems Reconstruction Texture prefiltering, mipmaps

MIT EECS Quiz solution: Homogeneous sum (x 1, y 1, z 1, 1) + (x 2, y 2, z 2, 1) = (x 1 +x 2, y 1 +y 2, z 1 +z 2, 2) ¼ ((x 1 +x 2 )/2, (y 1 +y 2 )/2, (z 1 +z 2 )/2) This is the average of the two points General case: consider the homogeneous version of (x 1, y 1, z 1 ) and (x 2, y 2, z 2 ) with w coordinates w 1 and w 2 (x 1 w 1, y 1 w 1, z 1 w 1, w 1 ) + (x 2 w 2, y 2 w 2, z 2 w 2, w 2 ) = (x 1 w 1 +x 2 w 2, y 1 w 1 +y 2 w 2, z 1 w 1 +z 2 w 2, w 1 +w 2 ) ¼ ((x 1 w 1 +x 2 w 2 )/(w 1 +w 2 ),(y 1 w 1 +y 2 w 2 )/(w 1 +w 2 ), (z 1 w 1 +z 2 w 2 )/(w 1 +w 2 )) This is the weighted average of the two geometric points

MIT EECS Today’s lecture Antialiasing in graphics Sampling patterns Monte-Carlo Integration Probabilities and variance Analysis of Monte-Carlo Integration

MIT EECS 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!

MIT EECS 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

MIT EECS 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

MIT EECS 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

MIT EECS Anisotropy of the sampling grid More vertical and horizontal bandwidth –E.g. less bandwidth in diagonal A hexagonal grid would be better –Max anisotropy –But less practical

MIT EECS 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 imageBicubic upsampling

MIT EECS 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

MIT EECS Questions?

MIT EECS Today’s lecture Antialiasing in graphics Sampling patterns Monte-Carlo Integration Probabilities and variance Analysis of Monte-Carlo Integration

MIT EECS 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

MIT EECS Uniform supersampling Compute image at resolution k*width, k*height Downsample using low-pass filter (e.g. Gaussian, sinc, bicubic)

MIT EECS 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

MIT EECS Multisampling vs. supersampling Observation: –Edge aliasing mostly comes from visibility/rasterization issues –Texture aliasing can be prevented using prefiltering Multisampling idea: –Sample rasterization/visibility at a higher rate than shading/texture In practice, same as supersampling, except that all the subpixel get the same color if visible

MIT EECS Multisampling vs. supersampling For each triangle For each pixel Compute pixelcolor //only once for all subpixels For each subpixel If (all edge equations positive && zbuffer [subpixel] > currentz ) Then Framebuffer[subpixel]=pixelcolor The subpixels of a pixel get different colors only at edges of triangles or at occlusion boundaries Subpixels in supersampling Subpixels in multisampling Example: 2 Gouraud- shaded triangles

MIT EECS Questions?

MIT EECS Uniform supersampling Problem: supersampling only pushes the problem further: The signal is still not bandlimited Aliasing happens

MIT EECS 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

MIT EECS Jittered supersampling Regular, Jittered Supersampling

MIT EECS 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)

MIT EECS Poisson disk sampling and blue noise Essentially random points that are not allowed to be closer than some radius r Dart-throwing algorithm: Initialize sampling pattern as empty Do Get random point P If P is farther than r from all samples Add P to sampling pattern Until unable to add samples for a long time r From Hiller et al.

MIT EECS Poisson disk sampling and blue noise Essentially random points that are not allowed to be closer than some radius r The spectrum of the Poisson disk pattern is called blue noise: No low frequency Other criterion: Isotropy (frequency content must be the same for all direction) Poisson disk patternFourier transform Anisotropy (power spectrum per direction)

MIT EECS Recap Uniform supersampling –Not so great Jittering –Great, replaces aliasing by noise Poisson disk sampling –Equally good, but harder to generate –Blue noise and good (lack of) anisotropy

MIT EECS Adaptive supersampling Use more sub-pixel samples around edges

MIT EECS 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

MIT EECS 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

MIT EECS Problem with non-uniform distribution Reconstruction can be complicated 80% of the samples are black Yet the pixel should be light grey

MIT EECS Problem with non-uniform distribution Reconstruction can be complicated Solution: do a multi-level reconstruction –Reconstruct uniform sub-pixels –Filter those uniform sub-pixels

MIT EECS Recap Uniform supersampling –Not so great Jittering –Great, replaces aliasing by noise Poisson disk sampling –Equally good, but harder to generate –Blue noise and good (lack of) anisotropy Adaptive sampling –Focus computation where needed –Beware of false negative –Complex reconstruction

MIT EECS Questions?

MIT EECS Today’s lecture Antialiasing in graphics Sampling patterns Monte-Carlo Integration Probabilities and variance Analysis of Monte-Carlo Integration

MIT EECS Shift of perspective So far, Antialiasing as signal processing Now, Antialiasing as integration Complementary yet not always the same

MIT EECS Why integration? Simple version: compute pixel coverage More advanced: Filtering (convolution) is an integral pixel = s filter * color And integration is useful in tons of places in graphics

MIT EECS Monte-Carlo computation of  Take a square Take a random point (x,y) in the square Test if it is inside the ¼ disc (x 2 +y 2 < 1) The probability is  /4 x y

MIT EECS Monte-Carlo computation of  The probability is  /4 Count the inside ratio n = # inside / total # trials   n * 4 The error depends on the number or trials

MIT EECS Why not use Simpson integration? Yeah, to compute , Monte Carlo is not very efficient But convergence is independent of dimension Better to integrate high-dimensional functions For d dimensions, Simpson requires N d domains

MIT EECS Dumbest Monte-Carlo integration Compute 0.5 by flipping a coin 1 flip: 0 or 1=> average error =0.5 2 flips: 0, 0.5, 0.5 or 1 =>average error= flips: 0 (*1),0.25 (*4), 0.5 (*6), 0.75(*4), 1(*1) => average error = Does not converge very fast Doubling the number of samples does not double accuracy

MIT EECS Questions?

MIT EECS Today’s lecture Antialiasing in graphics Sampling patterns Monte-Carlo Integration Probabilities and variance Analysis of Monte-Carlo Integration BEWARE: MATHS INSIDE

MIT EECS Review of probability (discrete) Random variable can take discrete values x i Probability p i for each x i 0 · p i · 1 If the events are mutually exclusive,  p i =1 Expected value Expected value of function of random variable –f(x i ) is also a random variable

MIT EECS Ex: fair dice

MIT EECS Variance & standard deviation Variance  2 : Measure of deviation from expected value Expected value of square difference (MSE) Also Standard deviation  : square root of variance (notion of error, RMS)

MIT EECS Questions?

MIT EECS Continuous random variables Real-valued random variable x Probability density function (PDF) p(x) –Probability of a value between x and x+dx is p(x) dx Cumulative Density Function (CDF) P(y): –Probability to get a value lower than y

MIT EECS Properties p(x) ¸ 0 but can be greater than 1 !!!! P is positive and non-decreasing

MIT EECS Properties p(x) ¸ 0 but can be greater than 1 !!!! P is positive and non-decreasing

MIT EECS Example Uniform distribution between a and b Dirac distribution

MIT EECS Expected value Expected value is linear E[f 1 (x) + a f 2 (x)] = E[f 1 (x)] + a E[f 2 (x)]

MIT EECS Variance Variance is not linear !!!!  2 [x+y] =  2 [x] +  2 [y] + 2 Cov[x,y] Where Cov is the covariance –Cov[x,y] = E[xy] - E[x] E[y] –Tells how much they are big at the same time –Null if variables are independent But  2 [ax] = a 2  2 [x]