Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Anti-Aliasing
Overview
Super Sampling Area Sampling (prefiltering) Weighting (postfiltering)
Computer Graphics & Visualization
Pedher Johansson
Department of Computing Science, Ume University
Antialiasing
Aliasing, jagged edges or staircasing can be reduced by:
Higher screen resolution
- Need a huge frame buffer
Antialiasing Techniques
Super Sampling
Compute intensities at sub-pixel grid positions and combine the results to obtain the pixel intensity.
Antialiasing techniques
- Vary pixel intensities along boundaries to smooth the edge.
Area Sampling
Find pixel intensity by calculating the areas of overlap of each pixel within the objects to be displayed.
Pedher Johansson
Department of Computing Science, Ume University
Pedher Johansson
Department of Computing Science, Ume University
Pedher Johansson
Department of Computing Science, Ume University
Pedher Johansson
Department of Computing Science, Ume University
Postfiltering
Equal areas can contribute to unequal intensity. A weighted avarage.
Filter Functions
Optimal filters are computationally more expensive. Cone filters are a very reasonable compromise between cost and quality.
Weigting Masks
Predefined table values for each subpixel
Filtering Techniques
Includes neighbouring pixels
Pedher Johansson
Department of Computing Science, Ume University
Pedher Johansson
Department of Computing Science, Ume University
Anti-Aliasing
Line Intensity Differences:
The diagonal line appears less bright than the horizontal. Total intensity is proportional to their length.
Pedher Johansson
Department of Computing Science, Ume University
Pedher Johansson
Department of Computing Science, Ume University
Clipping Algorithms
Line Clipping:
Cohen-Suterland (encoding)
- Oldest and most commonly used
Cohen-Sutherland Line-Clipping
1. Encode end points Bit 0 = point is left of window Bit 1 = point is right of window Bit 2 = point is below window Bit 3 = point is above window If C0 Cend 0 then P0Pend is trivially rejected If C0 Cend = 0 then P0Pend is trivially accepted Otherwise subdivide and go to step 1 with new segment.
Computer Graphics & Visualization
1001
1000
1010
0001
0000
0010
2.
Polygon Clipping:
Sutherland-Hodgeman
Divide and conquer strategy 4. 3.
0101
0100
0110
C0 =
Bit code of P0
Cohen-Sutherland Line-Clipping
Clip order: Left, Right, Bottom, Top 1) A1C1 2) B1C1 3) reject 1) 2) 3) 4) 5) A2E2 B2E2 1001 B2D2 B2C2 accept A1 0001 C1 B1 1000 C2 B2 0000 A3 A2 0101 D3
Computer Graphics & Visualization
Pedher Johansson
Department of Computing Science, Ume University
Cohen-Sutherland Line-Clipping
E2
1010 D2
Will do unnecessary clipping. Efficient when most of the lines to be clipped are either rejected or accepted (not so many subdivisions). Easy to program
0010
1) 2) 3) 4)
C3
B3 0100
0110
Pedher Johansson
Department of Computing Science, Ume University
Parametric form
A line segment with endpoints (x0, y0) and (xend, yend) we can describe in the parametric form x = x0 + ux y = x0 + uy where x = xend x0 y = yend y0
Computer Graphics & Visualization
Pedher Johansson
Department of Computing Science, Ume University
Liang-Barsky Line-Clipping
More efficient than Cohen-Sutherland A line is inside the clipping region for values of u such that: xwmin x0 + ux xwmax x = xend x0 ywmin y0 + uy ywmax y = yend y0 Can be described as u pk qk, k = 1, 2, 3, 4
Computer Graphics & Visualization
Pedher Johansson
Department of Computing Science, Ume University
0u1
Liang-Barsky Line-Clipping
The infinitely line intersects the clip region edges when:
p1 = x p2 = x qk uk = where p3 = y pk p4 = y q1 = x0 xwmin q2 = xwmax x0 q3 = y0 ywmin q4 = ywmax y0
Liang-Barsky Line-Clipping
When pk < 0, as u increases
- line goes from outside to inside - entering
When pk > 0,
Left boundary Right boundary Bottom boundary Top boundary - line goes from inside to outside - exiting
When pk = 0,
- line is parallel to an edge
If there is a segment of the line inside the clip region, a sequence of infinite line intersections must go: entering, entering, exiting, exiting
Computer Graphics & Visualization
Pedher Johansson
Department of Computing Science, Ume University
Pedher Johansson
Department of Computing Science, Ume University
Liang-Barsky Line-Clipping
Enter Exit Enter Enter Enter Exit Exit Exit Clip region
Liang-Barsky Line-Clipping
1. Set umin = 0 and umax = 1. 2. Calculate the u values: 3. If u < umin or u > umax ignore it. Otherwise classify the u values as entering or exiting. 4. If umin < umax then draw a line from:
( x0 + x umin, y0 + y umin ) to ( x0 + x umax, y0 + y umax )
Pedher Johansson
Department of Computing Science, Ume University
Pedher Johansson
Department of Computing Science, Ume University
Example Liang-Barsky
P0(-5,3)
0,10
10,10 Pend(15,9)
Liang-Barsky Line-Clipping
We have uenter = 1/4 and uleave = 3/4
0,0
uleft =
Example Liang-Barsky
P0(-8,2)
0,10
Pend(2,14)
10,10
Liang-Barsky Line-Clipping
We have uenter = 4/5 and uleave = 2/3
0,0 10,0
Entering uenter = 4/5
uleft =
Pend - P0 = (2+8, 14-2) = (10, 12) uenter > uleave , there is no line segment do draw
uright =
ubottom = utop =
q4 ywmax y0 10 2 2 = = = 14 2 3 p4 y
Computer Graphics & Visualization
Pedher Johansson
Department of Computing Science, Ume University
T R B
If P0 is to the left:
LT
L
inside
edge region
corner region
T L LR L LB
T
P0
L
TR
LB
TB
Pedher Johansson
Pedher Johansson
Department of Computing Science, Ume University