Aliasing and Anti-Aliasing Copyright Zachary Wartell, University of North Carolina at Charlotte, All...

26
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 Wartell - 1/26/2005
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    220
  • download

    2

Transcript of Aliasing and Anti-Aliasing Copyright Zachary Wartell, University of North Carolina at Charlotte, All...

Page 1: 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.

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 Wartell - 1/26/2005

Page 2: 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.

Describe what you see!

(Hint)

Example A

Example B

©Zachary Wartell - 1/26/2005

Page 3: 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.

Reconstructed Signal (Low Frequency)

Describe what you see!

Sampling (Lower Frequency)

Signal (High Frequency)

Reconstruction

Reconstructed Signal (Low Frequency)

Example A

Example B

ReconstructionReconstructed Signal (Low freq.)

Sampling (Lower Frequency)

Signal (High Frequency)

©Zachary Wartell - 1/26/2005

Page 4: 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.

Describe what you see!

Sampling (Lower Frequency)

Signal (High Frequency)

Reconstruction

Reconstructed Signal (Low Frequency)

Example A

Aliasing = a high frequency signal masquarading as a low frequency signal due to a poor sampling

frequency.

©Zachary Wartell - 1/26/2005

Page 5: 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.

position

inte

nsity

Recall: frequency, cycle/wavelength

Δxcycle

sin 2 /

is amplitude

is wavelength

(ignoring y-offset and phase shift)

1/ frequency

cycle

cycle

cycle

y A x x

A

x

f x

A

Page 6: 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.

What is a “poor sampling frequency”?

Nyquist Sampling Frequency:

fs = 2 fmax

Δxs = Δxcycle / 2

fs : Nyquist Sampling Frequencyfmax : maximum frequency component in signalΔxs : Nyquist Sampling IntervalΔxcycle : Cycle interval

“To avoid losing information we need to set sampling frequency to at least twice the highest frequency component of signal.”©Zachary Wartell - 1/26/2005

Δx, f = 1/ΔxΔt, f = 1/Δt

space or time

ampl

itude

Δx, f = 1/ΔxΔt, f = 1/Δt

space or time

ampl

itude

Page 7: 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.

TADA!highest freq.comp. of S(x)

Example of highest frequency component

● What is highest frequency component of this signal, S(x)?

● What if I tell you the equation is:

Sin[x (2 Pi /10)] + Sin[x (2 Pi / 1)]*0.25

= +

f= 1/10, a=1

Sin[x (2 Pi / 1)]*0.25Sin[x (2 Pi /10)]

f= 1, a=0.25

Page 8: 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.

Highest frequency component of general signal

Any signal represented as sum of sinusoids:Amplitude vs Space

Input Signal S

=+

+

+

+ …

©Zachary Wartell - 1/26/2005

Page 9: 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.

Fourier Transform

Amplitude vs Frequency

Input Signal S

=+

++

+ …∑

Insensity vs Position

=

©Zachary Wartell - 1/26/2005 f

af -how much does frequency f contribute to the original signal S

sinusoid a frequency f of amplitude af

Page 10: 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.

How does this relate to image capture?

-”real” image is a 2D signal of infinite resolution- the sampled image is of finite resolution (finite # of pixels)-the original image contains details that are very much smaller than the pixel sampling rate, result is jagged lines/boundaries

- high detail means high frequency components- jagged lines/boundaries is aliasing

“real” image - 2D Signal (“Mia”)

©Zachary Wartell - 1/26/2005

sampled image - (“Eye”)

Page 11: 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.

Sampling “Mia” signal at too low frequency

©Zachary Wartell

“1D” Slice

Signal

Sample

Reconstruction ()

©Zachary Wartell - 1/26/2005

Page 12: 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.

Anti-Aliasing Options (Lines)

increase sampling rate with more pixels in framebuffer & displayUse same framebuffer resolution but enable multiple pixels based on pixel coverage pre-filter image - remove high frequenciesbefore sampling

area sampling – calculate area of overlap of each pixel with displayed primitives

supersampling (post-filter) – use more framebufferpixels and “average” intensities of groups of super-pixels results to the lower resolution actual pixels

©Zachary Wartell - 1/26/2005

Page 13: 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.

-Bresenham's line algorithm can be modified to account for pixel coverage [Gupta-Sproull]. We treat line as 1 pixel thick rectangle which can intersect up to 3 pixels and use a measure of the distance (D?) from line to the upper (Pk+1

u), standard (Pk+1) and lower pixel (Pk+1

l) to compute the weight each pixels intensity.

Use Pixel Coverage

Pαu

Pαl

Mk

Pk Pα

Du

Dl

D

Pαu

Pαu

Pαl

Pαl

Mk

Pk Pα

Du

Dl

D

Figure 13: Assume case Pk+1=Pα. Distances Du,D,Dl are functions of decision parameter (pk). Each distance used to get a intensity weighting from a pre-computed lookup table

©Zachary Wartell - 1/26/2005

Page 14: 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.

Supersampling Straight-Line Segments

supersample subpixel positions of zero-width line

2 3 4

2

3

4

Intensity of pixel Pis number ofsub-pixels turned onin P

©Zachary Wartell - 1/26/2005

Page 15: 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.

Supersampling Straight-Line Segments

©Zachary Wartell

supersample subpixel positions of finite-width line

2 3 4

2

3

4

-Intensity of pixel Pis number ofsub-pixels turned onin P

-Use lower left corner rule

-Also “pick-up” color ofbackground

©Zachary Wartell - 1/26/2005

Page 16: 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.

Subpixel Weighting Masks (Discrete Array)

2 3 4

2

3

4

1

1

1

1

2

2

2 24

-Mask (sum to 16)

©Zachary Wartell - 1/26/2005

Page 17: 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.

Area Sampling Straight-Line Segments

©Zachary Wartell©Zachary Wartell

Compute pixel to rectangle intersection area (trapezoid)

2 3 4

2

3

4

©Zachary Wartell - 1/26/2005

Page 18: 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.

Filtering Techniques (Continuous Function)

Box Cone Gaussian

-Integrate over volume-Highest potential accuracy (= slow)

Sinc(sin θ/θ)

©Zachary Wartell - 1/26/2005

Page 19: 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.

Line-Intensity and Line Angle

√2 * L

L

©Zachary Wartell - 1/26/2005

Page 20: 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.

Anti-aliasing boundaries: Pixel Coverage

-adjust intensity on boundary

x x+1

y

y+1

©Zachary Wartell - 1/26/2005

Page 21: 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.

Anti-aliasing boundaries: Supersampling

2 3 4

2

3

4

©Zachary Wartell - 1/26/2005

Page 22: 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.

Anti-aliasing boundaries: Pitteway & Watkinson

-variant of Bresenham Midpoint decision parameter p (assume m in [0,1])

xk

yk

yk+1

xk+1

Mk

L: y=mx+b

Pk

yk+1/2

©Zachary Wartell - 1/26/2005

Page 23: 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.

Anti-aliasing boundaries: Pitteway & Watkinson

xk

yk

yk+1

xk+1

Mk

L: y=mx+b

Pk

yk+1/2

xk

yk

yk+1

xk+1

Mk

L: y=mx+b

Pk

yk+1/2

add 1 – m, p [0,1]

p = [m(xk+1) + b] – (yk + ½) + (1-m)

Pα ↔ p < 1 – m and Pβ ↔ p > 1 – m

©Zachary Wartell - 1/26/2005

Page 24: 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.

Anti-aliasing boundaries: Pitteway & Watkinson

Insight: p = [m(xk+1) + b] – (yk + ½) + (1-m) =coverage area = m xk + b – yk + ½

xk- 1/2 xk+ 1/2xk

yk+1/2

yk-1/2

yk

y = m (xk+ ½) + b

y = m (xk- ½) + b

Atrap=B H0 + ½ B (H1 - H0 )

©Zachary Wartell - 1/26/2005

Page 25: 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.

Anti-Aliasing: Nvidia

-GeForce 4 has Accuview “multi-sampling”:

“1. Subpixels are rendered in parallel (thanks to multisampling technology) to a back buffer. This back buffer is a factor that is larger than the final display resolution.2. The image is filtered and written out to a front frame buffer.3. The frame buffer is sent to the display.”

-GeForce 8800 uses “coverage samples”…, and is Coverage Sampling Antialiasing (CSAA).

“CSAA provides higher levels of AA than with current 4x or 8x multisampling AA. CSAA modes include 8x, 16x and 16xQ.

CSAA produces antialiased images that rival the quality of 8x or 16x MSAA, while introducing only a minimal performance hit over standard (typically 4x) MSAA. ”

©Zachary Wartell - 1/26/2005

Page 26: 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.

Revisions

-1.2 – update with 8800 GPU commentary-to tedious s to keep this updated see SVN logs