Antialiasing CS 319 Advanced Topics in Computer Graphics John C. Hart.

Slides:



Advertisements
Similar presentations
Sampling, Aliasing.
Advertisements

Sampling and Reconstruction
Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
David Luebke 1 4/28/2015 Aliasing & Antialiasing.
Computer Graphics Viewing, Rendering, Antialiasing گرد آوري و تاليف: دكتر احمد رضا نقش نيل چي دانشگاه اصفهان گروه مهندسي كامپيوتر.
David Luebke1/19/99 CS 551/651: Antialiasing David Luebke
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
Advanced Computer Graphics (Fall 2010) CS 283, Lecture 3: Sampling and Reconstruction Ravi Ramamoorthi Some slides.
Sampling, Aliasing, & Mipmaps
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.
Aliasing and Anti-Aliasing Copyright Zachary Wartell, University of North Carolina at Charlotte, All Rights Reserved Revision: 10/24/2007 3:38:00 AM ©Zachary.
Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 3: Sampling and Reconstruction Ravi Ramamoorthi
Computational Photography: Fourier Transform Jinxiang Chai.
CIS 681 Distributed Ray Tracing. CIS 681 Anti-Aliasing Graphics as signal processing –Scene description: continuous signal –Sample –digital representation.
Image Sampling Moire patterns -
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
G52IIP, School of Computer Science, University of Nottingham 1 Image Transforms Fourier Transform Basic idea.
© 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.
Topic 7 - Fourier Transforms DIGITAL IMAGE PROCESSING Course 3624 Department of Physics and Astronomy Professor Bob Warwick.
Antialiasing CptS 548 Advanced Computer Graphics John C. Hart.
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.
Image Synthesis Rabie A. Ramadan, PhD 3. 2 Our Problem.
IMAGE SAMPLING AND IMAGE QUANTIZATION 1. Introduction
Antialiasing CAP4730: Computational Structures in Computer Graphics.
CS 450: COMPUTER GRAPHICS ANTIALIASING SPRING 2015 DR. MICHAEL J. REALE.
09/19/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Dithering.
Digital image processing Chapter 3. Image sampling and quantization IMAGE SAMPLING AND IMAGE QUANTIZATION 1. Introduction 2. Sampling in the two-dimensional.
Image Processing Basics. What are images? An image is a 2-d rectilinear array of pixels.
CS418 Computer Graphics John C. Hart
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.
Vibrationdata 1 Unit 6a The Fourier Transform. Vibrationdata 2 Courtesy of Professor Alan M. Nathan, University of Illinois at Urbana-Champaign.
Lecture 6 Rasterisation, Antialiasing, Texture Mapping,
02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.
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.
2D Sampling Goal: Represent a 2D function by a finite set of points.
Sampling Theorem & Antialiasing
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.
Antialiasing. What is alias? Alias - A false signal in telecommunication links from beats between signal frequency and sampling frequency (from dictionary.com)
Sampling Week 7, Fri 17 Oct 2003 p1 demos sampling.
Advanced Computer Graphics
… Sampling … … Filtering … … Reconstruction …
Image Sampling Moire patterns
Distributed Ray Tracing
Sampling Theorem & Antialiasing
Sampling and Antialiasing
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.
Joshua Barczak CMSC435 UMBC
Image Sampling Moire patterns
CSCE 643 Computer Vision: Image Sampling and Filtering
CSCE 643 Computer Vision: Thinking in Frequency
Distributed Ray Tracing
Filtering Part 2: Image Sampling
Image Sampling Moire patterns
Presentation transcript:

Antialiasing CS 319 Advanced Topics in Computer Graphics John C. Hart

Aliasing Aliasing occurs when signals are sampled too infrequently, giving the illusion of a lower frequency signal alias noun (c. 1605) an assumed or additional name f(t) = sin 1.9  t Plotted for t  [1,20] Sampled at integer t Reconstructed signal appears to be f(t) = sin 0.1  t

Zone Plate f(x,y) = sin(x 2 + y 2 ) Gray-level plot above –Evaluated over [-10,10] 2 –1000  1000 samples (more than needed) –Frequency = (x 2 + y 2 )/2  –About 30Hz (cycles per unit length) in the corners Poorly sampled version below –Only 100  100 samples –Moire patterns in higher frequency areas –Moire patterns resemble center of zone plate –Low frequency features replicated in under-sampled high frequency regions

Image Functions Analog image –2-D region of varying color –Continuous –e.g. optical image Symbolic image –Any function of two real variables –Continuous –e.g. sin(x 2 + y 2 ), theoretical rendering Digital image –2-D array of uniformly spaced color “pixel” values –Discrete –e.g. framebuffer

Photography Analog Image Scanning Digital Image Analog Image Display

Graphics Symbolic Image Rendering Digital Image Analog Image Display

Sampling and Reconstruction Continuous Image Sampling Continuous Image Discrete Samples Reconstruction p p Reconstruction Kernel 11 Sampling Function

1-D Fourier Transform Makes any signal I(x) out of sine waves Converts spatial domain into frequency domain Yields spectrum F(u) of frequencies u –u is actually complex –Only worried about amplitude: |u| DC term: F(0) = mean I(x) Symmetry: F(-u) = F(u) I x F u 0 p 1/p SpatialFrequency

Product and Convolution Product of two functions is just their product at each point Convolution is the sum of products of one function at a point and the other function at all other points E.g. Convolution of square wave with square wave yields triangle wave Convolution in spatial domain is product in frequency domain, and vice versa –f*g  FG –fg  F*G

Sampling Functions Sampling takes measurements of a continuous function at discrete points Equivalent to product of continuous function and sampling function Uses a sampling function s(x) Sampling function is a collection of spikes Frequency of spikes corresponds to their resolution Frequency is inversely proportional to the distance between spikes Fourier domain also spikes Distance between spikes is the frequency p 1/p s(x)s(x) S(u)S(u) Spatial Domain Frequency Domain

Sampling p 1/p I(x)I(x) s(x)s(x) (Is)(x) (Is’)(x) s’(x) F(u)F(u) S(u)S(u) (F*S)(u) S’(u) (F*S’)(u) Aliasing, can’t retrieve original signal

Shannon’s Sampling Theorem Sampling frequency needs to be at least twice the highest signal frequency Otherwise the first replica interferes with the original spectrum Sampling below this Nyquist limit leads to aliasing Conceptually, need one sample for each peak and another for each valley max {u : F(u) >  } 1/p > 2 max u

Prefiltering Aliases occur at high frequencies –Sharp features, edges –Fences, stripes, checkerboards Prefiltering removes the high frequency components of an image before it is sampled Box filter (in frequency domain) is an ideal low pass filter –Preserves low frequencies –Zeros high frequencies Inverse Fourier transform of a box function is a sinc function sinc(x) = sin(x)/x Convolution with a sinc function removes high frequencies DC Term Spatial Domain Frequency Domain sinc(x) I(x)I(x)F(u)F(u) (I*sinc)(x)(F box)(u) box(u)

Prefiltering Can Prevent Aliasing (Is’)(x) s’(x)S’(u) (F*S’)(u) I’ = (I*sinc) (F’*S’)(u) (I’s’)(x) F’ = (F box) (box)(F’*S’)(u) (sinc)*(I’s’)(x)

2-D Fourier Transform Converts spatial image into frequency spectrum image Distance from origin corresponds to frequency Angle about origin corresponds to direction frequency occurs hor. freq. vert. freq. DC diag. / freq. diag. \ freq.

Analytic Diamond Example: a Gaussian diamond function I(x,y) = e -1 – e -|x| – |y| Fourier transform of I yields Spectrum has energy at infinitely high horizontal and vertical frequencies Limited bandwidth for diagonal frequencies Dashed line can be placed arbitrarily close to tip of diamond, yielding a signal with arbitrarily high frequencies I(x,y) < 0 01 F(u,v)F(u,v)

Sampled Diamond Sample every 0.1 units: Sampling frequency is 10 Hz (samples per unit length) Frequencies overlap with replicas of diamond’s spectrum centered at 10Hz Aliasing causes blocking quantization artifacts Frequencies of staircase edge include ~10 Hz and ~20 Hz copies of diamond’s analytical spectrum centered about the DC (0Hz) term

Diamond Edges Plot one if I(x,y)  0, otherwise zero Aliasing causes “jaggy” staircase edges Frequencies of staircase edge include ~10 Hz and ~20 Hz copies of diamond’s analytical spectrum centered about the DC (0Hz) term

Antialiasing Strategies Pixel needs to represent average color over its entire area 1.Prefiltering –averages the image function so a single sample represents the average color –Limits bandwidth of image signal to avoid overlap 2.Supersampling –Supersampling averages together many samples over pixel area –Moves the spectral replicas farther apart in frequency domain to avoid overlap PrefilteringSupersampling

Cone Tracing Amanatides SIGGRAPH 84 Replace rays with cones Cone samples pixel area Intersect cone with objects –Analytic solution of cone-object intersection similar to ray-object intersection –Expensive Images courtesy John Amanatides

Beam Tracing Heckbert & Hanrahan SIGGRAPH 84 Replace rays with generalized pyramids Intersection with polygonal scenes –Plane-plane intersections easy, fast –Existing scan conversion antialiasing Can perform some recursive beam tracing –Scene transformed to new viewpoint –Result clipped to reflective polygon

Covers

Supersampling Trace at higher resolution, average results Adaptive supersampling –trace at higher resolution only where necessary Problems –Does not eliminate aliases (e.g. moire patterns) –Makes aliases higher-frequency –Due to uniformity of samples

Stochastic Sampling Eye is extremely sensitive to patterns Remove pattern from sampling Randomize sampling pattern Result: patterns -> noise Some noises better than others Jitter: Pick n random points in sample space –Easiest, but samples cluster Uniform Jitter: Subdivide sample space into n regions, and randomly sample in each region –Easier, but can still cluster Poisson Disk: Pick n random points, but not too close to each other –Samples can’t cluster, but may run out of room

Adaptive Stochastic Sampling Proximity inversely proportional to variance How to generate patterns at various levels? –Cook: Jitter a quadtree –Dippe/Wold: Jitter a k-d tree –Dippe/Wold: Poisson disk on the fly - too slow –Mitchell: Precompute levels - fast but granular

Reconstruction g(x1)g(x1) g(x2)g(x2) g(x3)g(x3) g(x4)g(x4) k

OpenGL Aliases Aliasing due to rasterization Opposite of ray casting New polygons-to-pixels strategies Prefiltering –Edge aliasing Analytic Area Sampling A-Buffer –Texture aliasing MIP Mapping Summed Area Tables Postfiltering –Accumulation Buffer

Analytic Area Sampling Ed Catmull, 1978 Eliminates edge aliases Clip polygon to pixel boundary Sort fragments by depth Clip fragments against each other Scale color by visible area Sum scaled colors

A-Buffer Loren Carpenter, 1984 Subdivides pixel into 4x4 bitmasks Clipping = logical operations on bitmasks Bitmasks used as index to lookup table

Texture Aliasing Image mapped onto polygon Occur when screen resolution differs from texture resolution Magnification aliasing –Screen resolution finer than texture resolution –Multiple pixels per texel Minification aliasing –Screen resolution coarser than texture resolution –Multiple texels per pixel

Magnification Filtering Nearest neighbor –Equivalent to spike filter Linear interpolation –Equivalent to box filter

Minification Filtering Multiple texels per pixel Potential for aliasing since texture signal bandwidth greater than framebuffer Box filtering requires averaging of texels Precomputation –MIP Mapping –Summed Area Tables

MIP Mapping Lance Williams, 1983 Create a resolution pyramid of textures –Repeatedly subsample texture at half resolution –Until single pixel –Need extra storage space Accessing –Use texture resolution closest to screen resolution –Or interpolate between two closest resolutions

Summed Area Table Frank Crow, 1984 Replaces texture map with summed-area texture map –S(x,y) = sum of texels <= x,y –Need double range (e.g. 16 bit) Creation –Incremental sweep using previous computations –S(x,y) = T(x,y) + S(x-1,y) + S(x,y-1) - S(x-1,y-1) Accessing –  T([x 1,x 2 ],[y 1,y 2 ]) = S(x 2,y 2 ) – S(x 1,y 2 ) – S(x 2,y 1 ) + S(x 1,y 1 ) –Ave T([x 1,x 2 ],[y 1,y 2 ])/((x 2 – x 1 )(y 2 – y 1 )) x2,y2x2,y2 x1,y1x1,y1 x,yx,y x-1,y-1

Accumulation Buffer Increases OpenGL’s resolution Render the scene 16 times Shear projection matrices Samples in different location in pixel Average result Jittered, but same jitter sampling pattern in each pixel