Motivation The main goal of Computer Graphics is to generate 2D images 2D images are continuous 2D functions (or signals) monochrome f(x,y) or color r(x,y), g(x,y), b(x,y) These functions are represented by a 2D set of discrete samples (pixels) Sampling can cause artifacts (=Aliasing) 2
Examples - Moiré Patterns 3
Examples - Jaggies Staircase effect at borders 4
Temporal Aliasing time real (continuous) motion sampled (perceived) motion 5
Aliasing in Computer Graphics Aliasing effects: loss of detail Moiré patterns jaggies Appear in texture mapping scan conversion of geometry raytracing 6
Sampling and Reconstruction 7
Example Point Sampling 8
Signal Processing Aliasing is well understood in signal processing Interpret images as 2D signals Aliasing = sampling of L 2 -functions below the Nyquist frequency u Nyquist = 2 u signal 9
Spectrum of an Image What is u signal of an image f(x,y)? Use Fourier analysis (1D first) Represent f(x) as a sum of harmonic waves: F j 2π u x f(x) = F(u)e du The amplitudes F(u) of waves with frequency u (spectrum) are computed as j 2π u x = f(x)e dx { f(x) } F(u) = 10
Avoiding Aliasing Let W be the maximum u for which F(u) >0 Either choose u sampling > 2W Or zero all F(u) for u > ½ u sampling i.e. low pass filter the signal Smoothing of image before sampling! e.g. Mip mapping: decreasing sampling rate, increased smoothing 11
1D Fourier Transform Fourier transform F Inverse transform F j 2π u x = f(x)e dx { f(x) } F(u) = -1 j 2π u x { F(u) } f(x) = = F(u)e du 12
1D Discrete Fourier Transform Discrete transform F(k) = 1 1 N N i= 0 f(i)e j 2π k i N Discrete inverse x = i x, u = k u N f(i) = = k 1 0 F(k)e Heisenberg resolution bounds j 2π k i N x u 1 4π 13
F F { f(x,y) } -1 Discrete setting = F(u,v) = { F(u,v) } = f(x,y) = 2D Fourier Transforms f(x,y)e f(x,y)e j 2π(u x+ v y) j 2π(u x+ v y) dx dy du dv F(u,v) = 1 1 1 M N M N x= 0 y= 0 f(x,y)e u x v y j 2π( + M N ) f(x,y) = M 1 N 1 u= 0 v= 0 F(u,v)e u x v y j 2π( + M N ) 14
Example: 2D Fourier Transforms rect(x,y) sinc(x,y) sine cardinal: sinc( x) = 1 sin( x) / x x = 0 otherwise 15
Reconstruction f(i x) g(x) x x reconstruction filter x f(x) x f(x) N = i=1 f ( i x) g( x i x) x 16
Convolutions f(x)*g(x) = f(α) g(x α) dα f(x) g(x) x x f(α) g(x-α) x α 17
Convolutions f(x) δ(x) x x Discrete setting f(x)* δ (x) = f(α)δ(x α)dα = f(x) f(x)*g(x) = M 1 m= 0 f(m) g(x m) 18
Convolutions 2D convolution as a separable TP-extension f(x,y)*g(x,y) = f(α, β) g(x α,y β)dα dβ Discrete form f(x,y)*g(x,y) = M 1 N 1 m= 0 n= 0 f(m,n) g(x m,y n) 19
Convolutions Convolution theorem f(x)*g(x) F(u)G(u) f(x)g(x) F(u)*G(u) For function of finite energy (L 2 ) f 2 = f,f = f(x) dx 2 < 20
Aliasing Sampling = multiplication with sequence of delta functions (impulse train) 21
Aliasing Multiplication converts to convolution in Fourier domain 22
Aliasing Convolution with sequence of delta functions = periodization 23
Aliasing Overlap of Fourier transforms leads to aliasing 24
Aliasing Reconstruction = Low pass filtering 25
Aliasing-free Reconstruction Spatial Domain Frequency Domain Spatial Domain Frequency Domain 26
Occurrence of Aliasing Spatial Domain Frequency Domain Spatial Domain Frequency Domain 27
2D Sampling 2D impulse fields f(x,y) δ(x x0,y y0 )dx dy = f(x0,y0 ) 28
Periodic spectrum of band limited sampled function Fourier Domain 29
Reconstruction Antialiasing Windowing spectrum using filters Simple f(x,y) = G(u,v) [ S(u,v)*F(u,v) ] where G(u,v) = 1 0 (u,v) else within Bounding Box of R 30
2D Sampling Theorem Sampling rate is bounded by u v Finite, discrete setting = = x y 1 N x 1 N y 1 2W u 1 2W v 31
32
Spectral Analysis Geometry 33
Antialiasing Filters in Practice Properties of a good low pass filter 34
Antialiasing Filters B-Spline filters of order n x 1 1 sin ω/ 2 sin π f g (x) 2 1 = = = 0 x > 1 ω/ 2 π f 2 sin c f Increase order by repeated convolution g n (x) = g 1(x)*g 1(x)* *g 1(x) sin c n f 35
36 Antialiasing Filters Gaussian filters Sinc-filter > = = c c c c c g x x sin x sinc ω ω ω ω ω ω ω ω 0 1 2 1 ) ( ) ( ) ( π π ) ( ) ( ) ( ω σ π ω π σ /σ / ω σ σ σ / σ 2 2 2 2 2 2 2 1 2 2 2 2 1 g e G e x g x = = =
Filters and Fourier Transforms 37
Filtering in Texture Space and Screen Space 38
The Concept of Resampling Filters Perspective projection of a textured surface Non-uniform sampling pattern on screen Optimal resampling filter is spatially variant 39
Projection and Image Warping Affine Mapping Projective Mapping 40
Relations between Texture and Image Space Texture space Image space warp 1. 4. 2. 3. 41
Spatially Variant Filtering Screen Space Texture Space 42
Antialiasing in Raytracing Supersampling Pixel 43
Jittering Random Perturbation of Sampling Positions 44
Poisson Sampling vs. Jittering 45
Supersampling & Jittering 4 Rays/Pixel Jitter=0.3 46
Supersampling & Jittering Jitter=0.5 Jitter=1.0 47
Supersampling & Jittering 4 Rays/Pixel Jitter=0.3 48
Supersampling & Jittering Jitter=0.5 Jitter=1.0 49
Adaptive Supersampling 50
Adaptive Supersampling 51