View
3.572
Download
0
Category
Tags:
Preview:
DESCRIPTION
helpful for assignment
Citation preview
CS 455 – Computer Graphics
Antialiasing
Aliasing• Aliasing: a high-frequency signal masquerading as a low
frequency
Caused by insufficient sampling (sampling interval too large)
SamplingInterval
Actual (high-frequency) signal
Sampled (aliased) signal
• Strobe light on dripping water: Temporal aliasing
• Spokes on a rotating wheel: Temporal aliasing
• Moiré patterns: Spatial aliasing
Examples of Aliasing
Aliasing and Line Drawing• We draw lines by sampling at intervals of one pixel and
drawing the closest pixels
SamplingInterval
SamplingInterval
• Results in stair-stepping (i.e., the dreaded “jaggies”)
Antialiasing Lines• Idea:
Make line “fatter” Fade line out (removes high frequencies) Now sample the line
Antialiasing LinesSolution 1 – Unweighted Area Sampling: Treat line as a single-pixel wide rectangle Color pixels according to the percentage of each pixel that is
“covered” by the rectangle
Solution 1: Unweighted Area Sampling• Pixel area is unit square
• Constant weighting function
• Pixel color is determined by computing the amount of the pixel covered by the line, then shading accordingly
• Easy to compute, gives reasonable results
Line
One Pixel
Solution 2: Weighted Area SamplingTreat pixel area as a circle with a radius of one pixel
Use a radially symmetric weighting function (e.g., cone): Areas closer to the pixel center are weighted more heavily
Better results than unweighted, slightly higher cost
Line
One Pixel
Solution 3: Gupta-Sproull algorithm• Calculate pixel intensity by computing distance from
pixel center to line using the midpoint line algorithm
xp
NE
m
E
xp+1
Line to draw
v
yp
yp+1
D
Gupta-Sproull algorithm (cont)• D is the perpendicular distance from E to the line
• How do we compute it?
a
How does triangle abc compare to triangle ade?
D
c = e, and a = a, so b must equal d
b
c
d e
dx
dy
v
r
r
Gupta-Sproull algorithm (cont)• D is the perpendicular distance from E to the line
• How do we compute it?
a
So:
D
22cos
dydx
vdxbvD
b
c
d e
22coscos
dydx
dxbd
dx
dy
v
r
r
€
cosb =D
v, then D = v cosb
And:
Then:
Gupta-Sproull algorithm (cont)Recall from the midpoint algorithm:
So
For pixel E:
So:
02),( cbyaxyxF
y
1px
v
xp
NE
m
E xp+1
Line to draw
vyp
yp+1
Db
cax
)(
1py py v 1 pyy1px
pp y
b
cxa
)1(
Gupta-Sproull algorithm (cont)From previous slide:
So
From the midpoint computation,
So:
dxb
pp
yb
cxav
)1(
2/),1()1( pppp yxFcbyxavdx
pp bycxabv )1(
xp
NE
m
E xp+1
Line to draw
vyp
yp+1
D
Gupta-Sproull algorithm (cont)From the midpoint algorithm, we had the decision
variable (remember?)
Going back to our previous equation:
)2
1,()( 1 pp yxFMFd
xp
NE
m
E xp+1
Line to draw
vyp
yp+1
D
),1(2 pp yxFvdx cbyxa pp 22)1(2
cbybxa pp 22/2)2/1(2)1(2 byxF pp )2/1,1(
bMF )( bd dxd
Gupta-Sproull algorithm (cont)So,
And the denominator is constant
Since we are blurring the line, we also need to compute the distances to points yp – 1 and yp + 1
222 dydx
dxdD
vdxdxdxvy
vdxdxdxvy
p
p
22)1(2 1for numerator
22)1(2 1for numerator
Gupta-Sproull algorithm (cont)If the NE pixel had been chosen:
vdxdxdxvy
vdxdxdxvy
p
p
22)1(2 for numerator
22)1(2 2for numerator
dxd
bd
bMF
byxF
cbybxa
cbyxa
yxFvdx
pp
pp
pp
pp
)(
)2/1,1(
22/2)2/1(2)1(2
2)1(2)1(2
)1,1(2
Gupta-Sproull algorithm (cont)• Compute midpoint line algorithm, with the following
alterations:
• At each iteration of the algorithm: If the E pixel is chosen, set numerator = d + dx If the NE pixel is chosen, set numerator = d – dx Update d as in the regular algorithm Compute D = numerator/denominator Color the current pixel according to D Compute Dupper = (2dx-2vdx)/denominator
Compute Dlower = (2dx+2vdx)/denominator
Color upper and lower accordingly
Solution 4: Super-sampling• Divide pixel up into “sub-pixels”: 22, 33, 44, etc.
• Sub-pixel is colored if inside line• Pixel color is the average of its sub-pixel colors• Easy to implement (in software and hardware)
No antialiasing Antialiasing (22 super-sampling)
Solution 5: Sum of Foreground and Background
• Compute percent of pixel covered by line, p
• Line color is cl
• Background color is cb
• Pixel color is the sum of this percent multiplied by the line color, plus the percent of the pixel not covered by the line multiplied by the background color, i.e.,
color = p * cl + (1-p) * cb
Polygon Antialiasing• To antialias a line, we treat it as a polygon (a rectangle)
• Antialiasing a polygon (or any shape primitive) is similar
• Some concerns: Corners: Complicate the coverage
computation
Micro-polygons: smaller than a pixel
Super-sampling: There may still bepolygons that “slip between the cracks”
Recommended