Upload
trinhnhan
View
215
Download
0
Embed Size (px)
Citation preview
CGT 511(Anti)aliasing(Anti)aliasing
dři h š hBedřich Beneš, Ph.D.
Purdue University
Department of Computer Graphics Technology
Aliasing• Aliasing is one of the most important properties of
sampling
C i f i f( ) i• Continuous function f(x) is discretized into I(i) by sampling
We loose some information• We loose some information
• How is this fact presented in the discrete image?
Wh i h diff b f( ) d I(i)?• What is the difference between f(x) and I(i)?
© Bedrich Benes
Aliasing
°°°°°°°°
°°°°°°°°
°°°°°°°°
°°°°°°°°
°°°°°°°°
°°°°°°°°
°°°°°°°°
°°°°°°°°
continuous function sampling space result
© Bedrich Benes
AliasingHaving originally continuous function
We get something else after its reconstructionWe get something else after its reconstruction
original
reconstructed
samples
© Bedrich Benes
Aliasing
the new (low frequency) information is called alias
Original function
liA sample
alias
© Bedrich Benes
Aliasing• Alias is ubiquitous for Computer Graphics
• Examples are• jaggies
• crowlies(animation)
°°°° °°°°
°°°°
°°°°
°°°°
°°°°
© Bedrich Benes
°°°° °°°°
Aliasing• Examples
• New patterns(moire)
© Gomez and Wehlo
• wagon wheel effect (aliasing in time domain)
© Bedrich Benes
Aliasing• Alias is a loss of information caused by
transition from continuous to discrete space.
• Aliasing artifacts are caused by high‐frequency information aliasing as a low‐frequency one.
• Can we avoid this? Practically no!yCan we decrease the error? Yes!
© Bedrich Benes
Antialiasing• (partial) elimination of alias is called
antialiasing
We have to add some information, so we have to sample better.… we need additional effort,… we have to compute more,… it takes longer time
© Bedrich Benes
Antialiasing• Antialiasing is a partial elimination of alias
• Can be done in two ways• Object antialiasing
(only one object is antialiased)
• Screen‐based antialiasingg(the entire image is antialiased)
© Bedrich Benes
Object Antialiasing
© Bedrich Benes© Bedrich Benes
11
Object Antialiasing
© Bedrich Benes
Scene Antialiasing
© Bedrich Benes
Sampling• Let’s have a close look at sampling
Sampling frequency 1Sampling frequency (i.e., how often we take the sample)
xf
1
point samplingpoint sampling takes exactly one value (usually in the middle)
© Bedrich Benes
(usually in the middle)
Sampling• area sampling
measures an average of the sampled area
xx
dttfxI )(1)( xx
• But the integral is hard to evaluate
© Bedrich Benes
SamplingLet’s use numerical methods! (i.e., n<)
nxx 11
n
ii
nx ndttf
xxI
1
1)(1)( lim
Where:n ‐ # of the samplesn # of the samples ‐ is a sample i.e., =f(t) is somewhere
© Bedrich Benes
f(t) is somewhere in the sampling area t<x, x+x>
SamplingThere are some special cases:
for n=1 we have point sampling method, for n‐> we have area sampling,
So the antialiasing picks something in the middle…
© Bedrich Benes
SupersamplingLet’s take n samples from the area
corresponding to a pixel over the originally continuous function
Estimate the value from the sampelsEstimate the value from the sampels.
This is an approximating the function.
Taking more samples from the <x, x+x>is called supersampling.
© Bedrich Benes
is called supersampling.
Supersampling• Depending on the way we take it
Regular (uniform)
R l i ki l i l i l
Random (stochastic)
Regular is taking samples in regular intervals and it shifts alias to higher frequencies
Stochastic involves random numbers changes alias to noise (noise is nicer for human visual
© Bedrich Benes
( fperception system)
Regular Supersampling• Digitalize the image in higher resolution
• Scale it down
• Use the average as the new colororiginal supersampling average scale downoriginal supersampling average scale down
© Bedrich Benes
Regular Supersampling
© Bedrich Benes
Regular Supersampling
original 3x3 uniform supersamplingg p p g
© Bedrich Benes
Regular Supersampling ‐ FSAA
Regular Supersampling also called
Full Screen Antialiasing (FSAA)Full Screen Antialiasing (FSAA)
is today’s state of the art
ti li i d iantialiasing used in games
© Bedrich Benes
Regular Supersampling
original 5x5 uniform supersamplingg p p g
© Bedrich Benes
Regular Supersampling
original 9x9 uniform supersamplingg p p g
© Bedrich Benes
Regular Supersampling• Antialiasing with regular SS
1) Digitalize image in 3x higher resolution
2) For each pixel of the small image doa) get the corresponding superpixels) g p g p pb) calculate average of their colorsc) apply the color) pp y
© Bedrich Benes
Regular Supersampling• Pros
• easy to do
• Can be done in HW
• Cons• image must be calculated in a higher resolution
(but who cares today…)
• blurs the image
• alias is shifted to higher frequencies
© Bedrich Benes
g q
Other Regular Supersampling• 1x2 or 2x1 supersampling
• more samples at one screen axis
© Bedrich Benes
Other Regular Supersampling• Rotated Grid Super Sampling (RGSS)
• samples in a rotated grid
• good for nearly horizontal edges
© Bedrich Benes
Other Regular Supersampling• Quincunx (NVIDIA)
High Resolution AA (HRAA)• four samples in corners, one in the center
• corners 1/8 weight, center ½
© Bedrich Benes
Supersampling• Depending on the way we take it
Regular (uniform)
R l i ki l i l i l
Random (stochastic)
Regular is taking samples in regular intervals and it shifts alias to higher frequencies
Stochastic involves random numbers changes alias to noise (noise is nicer for human visual
© Bedrich Benes
( fperception system)
Stochastic supersamplingcover the pixel by n random samples
assure well‐proportioned point distributionassure well proportioned point distribution
if the stochastic sampling is really random
this can happen inside one pixelthis can happen inside one pixel
© Bedrich Benes
and the image will be heavily noisy!
Stochastic supersamplingThe best covering is assured by
Poisson disc random number distributionPoisson disc random number distribution
Each sample is at least in distance dfar from the others
dd
d
|[xk,yk|‐[x,y]|>2dd
d
© Bedrich Benes
Poisson disc generatorSet list of points to empty
for (i=0;i<n;i++){repeat{repeat{generate a random point with uniform distribution A=[xk,yk]
}until there is NO point Slow!
|[xk,yk|-[x,y]|<2d add A to the list}// end of for
© Bedrich Benes
}// end of for
Jitteringan approximation of the
Poisson disc random numbers distribution
Uniform samples are jittered
the worst case that can happen:
© Bedrich Benes
Jittering
jittering
l jitt dregular supersampling
jitteredsupersampling
© Bedrich Benes
Jittering
original 3x3 jittered supersampling
© Bedrich Benes
Jittering
original 5x5 jittered supersampling
© Bedrich Benes
Jitteringjitt dl jittered
supersampling 3x3regular
supersampling 3x3
© Bedrich Benes
N‐rooks distributionApproximation of Poisson disc
Supersampling in superresolution n x nSupersampling in superresolution n x n
Put n samples as a spatial permutation of the diagonal
We have these matrices stored in memory andWe have these matrices stored in memory and we are taking them randomly.It is cheaper variant of jittering.
© Bedrich Benes
It is cheaper variant of jittering.
N‐rooks distribution
etc.
• Matrices are stored and taken randomly.
• It is cheaper variant of jittering.
© Bedrich Benes
Adaptive SupersamplingImagine the following continuous function:
sampling in 2x2 one partially covered pixel
there is no need to sample the others better!
© Bedrich Benes
Adaptive Supersampling• Idea – sample only when necessary
step 1 step 2 step 3 etc…
© Bedrich Benes
Adaptive Supersampling• The color value is then
B CB C
AE F
AD G
GFED
44)(
GFEDCBAxI
© Bedrich Benes
Summary• alias, examples
• sampling ‐ point areasampling point, area
• supersampling ‐ uniform, stochastic
• Poisson disc, Jittering, N‐rooks
• Adaptive supersampling
© Bedrich Benes
ReadingsReal‐time rendering, Tomas Akeine Mollner, Eric
Haines, AKPeters Ltd, 2002, pp.84‐101
Advanced Rendering and Animation Techniques, Watt Watt Addison‐Wesley Reading 1992Watt, Watt, Addison Wesley, Reading, 1992, pp.XX‐XX
© Bedrich Benes