1 of 64

Nima Kalantari

CSCE 441 - Computer Graphics

Antialiasing

Some slides from Ren Ng

2 of 64

Rasterization

3 of 64

This is Displayed

4 of 64

Compare: The Continuous Triangle Function

5 of 64

What’s Wrong With This Picture?

Jaggies!

6 of 64

Jaggies (Staircase Pattern)

Is this the best we can do?

7 of 64

Outline

  • Sampling & aliasing
  • Frequency domain
  • Antialiasing

8 of 64

Sampling

  • Ubiquitous in Computer Graphics and Imaging

9 of 64

Rasterization = Sample 2D Positions

10 of 64

Photograph = Sample Image Sensor Plane

11 of 64

Video = Sample Time

Harold Edgerton Archive, MIT

12 of 64

Sampling Artifacts in Graphics and Imaging

13 of 64

Jaggies (Staircase Pattern)

This is also an example of “aliasing” – a sampling error

14 of 64

Moiré Patterns in Imaging

lystit.com

Read every sensor pixel

Skip odd rows and columns

15 of 64

Wagon Wheel Illusion (False Motion)

Created by Jesse Mason, https://www.youtube.com/watch?v=QOwzkND_ooU

16 of 64

Aliasing in video

Slide by Steve Seitz

17 of 64

Aliasing in video

18 of 64

Sampling Artifacts in Computer Graphics

  • Artifacts due to sampling - “Aliasing”
    • Jaggies – sampling in space
    • Moire – undersampling images (and textures)
    • Wagon wheel effect – sampling in time
    • [Many more] …

  • Aliasing
    • Fast-changing signals (high frequency) sampled too slowly

19 of 64

Antialiasing

20 of 64

Video: Point vs Antialiased Sampling

Point in Time

Motion Blurred

21 of 64

Video: Point Sampling in Time

30 fps video. 1/800 second exposure is sharp in time, causes time aliasing.

Credit: Aris & cams youtube, https://youtu.be/NoWwxTktoFs

22 of 64

Rasterization: Point Sampling in Space

Note jaggies in rasterized triangle �where pixel values are pure red or white

Sample

23 of 64

Rasterization: Antialiased Sampling

Pre-Filter

Sample

Note antialiased edges in rasterized triangle�where pixel values take intermediate values

24 of 64

Point Sampling

25 of 64

Antialiased

26 of 64

Aliasing and Antialiasing

  • Why undersampling results in aliasing?
  • Why pre-filtering reduces aliasing?

27 of 64

Outline

  • Sampling & aliasing
  • Frequency domain
  • Antialiasing

28 of 64

Sines and Cosines

29 of 64

Frequencies

30 of 64

Fourier Transform

  • Represent a function as a weighted sum

of sines and cosines

Joseph Fourier 1768 - 1830

f0 +

31 of 64

Extension to 2D

Image as a sum of basis images

=

32 of 64

Constant

Frequency Domain

(0,0)

Spatial Domain

33 of 64

— frequency 1/32; 32 pixels per cycle

Max signal freq =1/32

(0,0)

Frequency Domain

Spatial Domain

34 of 64

— frequency 1/16; 16 pixels per cycle

Max signal freq =1/16

(0,0)

Frequency Domain

Spatial Domain

35 of 64

Frequency Domain

Spatial Domain

36 of 64

2D Frequency Space

Note: Frequency domain also known as frequency space, Fourier domain, spectrum, …

Frequency Domain

Spatial Domain

37 of 64

Sampling

  • Simple example: a sine wave

© 2006 Steve Marschner

38 of 64

Undersampling

  • What if we “missed” things between the samples?
  • Simple example: undersampling a sine wave
    • Unsurprising result: information is lost

© 2006 Steve Marschner

39 of 64

Undersampling

  • What if we “missed” things between the samples?
  • Simple example: undersampling a sine wave
    • Unsurprising result: information is lost
    • Surprising result: indistinguishable from lower frequency
    • Aliasing: high frequencies traveling in disguise as low frequencies

© 2006 Steve Marschner

40 of 64

Moiré Patterns in Imaging

lystit.com

Read every sensor pixel

Skip odd rows and columns

41 of 64

Higher Frequencies Need Faster Sampling

x

f1(x)

f2(x)

f3(x)

f4(x)

f5(x)

f2(x)

f1(x)

f3(x)

f4(x)

f5(x)

Periodic sampling locations

Low-frequency signal: sampled adequately for reasonable reconstruction

High-frequency signal is insufficiently sampled: reconstruction incorrectly appears to be from a low frequency signal

42 of 64

Nyquist Theorem

  • Sampling rate should be equal to or greater than twice the highest frequency in the analog signal

Signal Interval

Maximum Acceptable

Sampling Interval

43 of 64

Nyquist Theorem

  • Sampling rate should be equal to or greater than twice the highest frequency in the analog signal

44 of 64

Nyquist Theorem

  • Sampling rate should be equal to or greater than twice the highest frequency in the analog signal

45 of 64

Nyquist Theorem

  • Sampling rate should be equal to or greater than twice the highest frequency in the analog signal

46 of 64

Antialiasing

  • What can we do about aliasing?
    • Sample more often
      • Higher res displays, sensors, framebuffers
      • Only shifts the problem to higher frequencies
    • Make the signal less “wiggly” (filtering)
      • Get rid of some high frequencies
      • Will lose information
      • But it’s better than aliasing

47 of 64

Outline

  • Sampling & aliasing
  • Frequency domain
  • Antialiasing

48 of 64

Rasterization: Point Sampling in Space

Note jaggies in rasterized triangle �where pixel values are pure red or white

Sample

49 of 64

Rasterization: Antialiased Sampling

Pre-Filter

Sample

Note antialiased edges in rasterized triangle�where pixel values take intermediate values

50 of 64

A Practical Pre-Filter

  • One pixel-width box filter will attenuate frequencies whose period is less than or equal to 1 pixel-width

Spatial Domain

51 of 64

Antialiasing By Averaging Values in Pixel Area

  • The following are the same:�
  • Option 1:
    • Convolve scene by a 1-pixel box-blur
    • Then sample at every pixel
  • �Option 2:
    • Compute the average value of scene in the pixel

52 of 64

Antialiasing by Computing Average Pixel Value

  • In rasterizing one triangle, the average value inside a pixel area of f(x,y) = inside(triangle, x, y) is equal to the area of the pixel covered by the triangle.

  • Original

  • Filtered

1 pixel width

53 of 64

Super Sampling Antialiasing (SSAA)

54 of 64

Supersampling

  • We can approximate the effect of the 1-pixel box filter by sampling multiple locations within a pixel and averaging their values:

4x4 supersampling

55 of 64

Point Sampling: One Sample Per Pixel

56 of 64

Supersampling: Step 1

  • Take NxN samples in each pixel

2x2 supersampling

57 of 64

Supersampling: Step 2

  • Average the NxN samples “inside” each pixel

2x2 supersampling

58 of 64

Supersampling: Step 2

  • Average the NxN samples “inside” each pixel

2x2 supersampling

59 of 64

Supersampling: Step 2

  • Average the NxN samples “inside” each pixel

60 of 64

Supersampling: Result

This is the corresponding signal emitted by the display

75%

75%

100%

50%

50%

50%

50%

25%

61 of 64

Point Sampling

  • One sample per pixel

62 of 64

4x4 Supersampling

  • Pixel value is average of 4x4 samples per pixel

63 of 64

Sample Locations

(0,h)

(w,h)

(0,0)

(w,0)

Regular sampling: sample location for pixel (i,j)

(i+1/2,j+1/2)

64 of 64

Sample Locations

(i+1/4,j+3/4)

(i+1/4,j+1/4)

(i+3/4,j+1/4)

(i+3/4,j+3/4)

2x2 supersampling: locations for pixel (i,j)

(0,h)

(w,h)

(0,0)

(w,0)