ttributes for Graphics Output Primitives ttributes of Graphics Primitives in 2 points, lines polygons, circles, ellipses & other curves (also filled) characters in 3 triangles & other polygons anti-aliasing Werner Purgathofer / omputergraphik 1 1 Points and Line ttributes color type: solid, dashed, dotted, width, line caps, corners pen and brush options rea-ill ttributes (1) fill styles hollow, solid fill, pattern fill fill options edge type, width, color pattern specification through pattern tables tiling (reference point) 4 0 0 4 4 0 0 4 4 0 0 4 4 0 0 4 4 0 0 4 4 0 0 4 4 0 0 4 4 0 0 4 4 0 0 4 4 0 0 4 4 0 0 4 4 0 0 4 4 0 0 4 Werner Purgathofer / omputergraphik 1 2 Werner Purgathofer / omputergraphik 1 3 rea-ill ttributes (2) Polygon ill lgorithms combination of fill pattern with background colors soft fill combination of colors antialiasing at object borders simul. of semitransparent brushes example: linear soft-fill...foreground color...background color Werner Purgathofer / omputergraphik 1 4 pattern background and or xor replace P = t + (1 t) what is inside? scan-line fill method flood fill method interior, exterior for selfintersecting polygons? Werner Purgathofer / omputergraphik 1 5 1
Polygon ill lgorithms what is inside? scan-line fill method flood fill method Polygon ill lgorithms what is inside? scan-line fill method flood fill method interior pixels along a scan line passing through a polygon area Werner Purgathofer / omputergraphik 1 6 starting from a seed point fill until you reach a border Werner Purgathofer / omputergraphik 1 7 Inside-Outside Tests area-filling algorithms interior, exterior for self-intersecting polygons? odd-even rule nonzero winding number rule cross or dot product to determine winding number same result for simple polygons What is Inside?: Odd-ven Rule inside/outside switches at every edge straight line to the outside: even # edge intersections = outside odd # edge intersections = inside Werner Purgathofer / omputergraphik 1 8 Werner Purgathofer / omputergraphik 1 9 What is Inside?: Nonzero Winding Number Scan-Line ill: Sorted dge Table point is inside if polygon surrounds it straight line to the outside: same # edges up and down = outside different # edges up and down = inside y x 1/m y x 1/m y x 1/m y x 1/m The sorted edge table contains all polygon edges sorted by lowest y-value y max x start 1/m y x 1/m Werner Purgathofer / omputergraphik 1 10 Werner Purgathofer / omputergraphik 1 11 2
Scan-Line ill: Sorted dge Table Sorted dge Table sort all edges on smallest y-value edge entry: [max y-value, x-intercept, inverse slope] y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m active-edge list for each scan line contains all edges crossed by that scan line incremental update consecutive intersection pairs (spans) filled Werner Purgathofer / omputergraphik 1 12 Werner Purgathofer / omputergraphik 1 13 y x 1/m The sorted edge table contains all polygon edges sorted by lowest y-value y max x start 1/m y x 1/m Sorted dge Table / ctive dge List Sorted dge Table / ctive dge List y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m ctive dge List Werner Purgathofer / omputergraphik 1 14 When processing from bottom to top, keep a list of all active edges ctive dge List y x 1/m y x 1/m Werner Purgathofer / omputergraphik 1 15 incremental update! Sorted dge Table / ctive dge List Sorted dge Table / ctive dge List y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m ctive dge List ctive dge List y x 1/m y x 1/m y x 1/m Werner Purgathofer / omputergraphik 1 16 Werner Purgathofer / omputergraphik 1 17 3
Sorted dge Table / ctive dge List Sorted dge Table / ctive dge List y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m ctive dge List ctive dge List y x 1/m y x 1/m Werner Purgathofer / omputergraphik 1 18 Werner Purgathofer / omputergraphik 1 19 Sorted dge Table / ctive dge List Sorted dge Table / ctive dge List y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m ctive dge List ctive dge List y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m Werner Purgathofer / omputergraphik 1 20 Werner Purgathofer / omputergraphik 1 21 Sorted dge Table / ctive dge List Sorted dge Table / ctive dge List y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m ctive dge List ctive dge List y x 1/m y x 1/m Werner Purgathofer / omputergraphik 1 22 Werner Purgathofer / omputergraphik 1 23 4
Sorted dge Table / ctive dge List Sorted dge Table / ctive dge List y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m ctive dge List ctive dge List y x 1/m y x 1/m Werner Purgathofer / omputergraphik 1 24 Werner Purgathofer / omputergraphik 1 25 Sorted dge Table / ctive dge List y x 1/m y x 1/m y x 1/m y x 1/m y x 1/m ctive dge List Scan-Line ill: Incremental Update incremental update of intersection point slope of polygon boundary line: m x k+ = 1 x + k 1 m (for 2 successive scanlines) (x k+1, y k+1 ) (x k, y k ) y k = + 1 y 1 + k y k +1 y k Werner Purgathofer / omputergraphik 1 26 Werner Purgathofer / omputergraphik 1 27 Scan-Line ill: Intersecting Vertices intersection points along scan lines that intersect polygon vertices. 2 1 either special handling (1 or 2 intersections?) 2 2 1 lood-ill lgorithm pixel filling of area areas with no single color boundary start from interior point flood internal region 4-connected, 8-connected areas reduce stack size by eliminating several recursive calls or move vertices up or down by ε Werner Purgathofer / omputergraphik 1 28 Werner Purgathofer / omputergraphik 1 29 5
lood-ill: oundary and Seed Point lood-ill: onnectedness area must be distinguishable from boundaries seed point example: area defined within multiple color boundaries efinition: 4-connected means, that a connection is only valid in these 4 directions efinition: 8-connected means, that a connection is valid in these 8 directions Werner Purgathofer / omputergraphik 1 30 Werner Purgathofer / omputergraphik 1 31 xamples for 4- and 8-connected a 4-connected area has an 8-connected border Werner Purgathofer / omputergraphik 1 32 an 8-connected area has a 4-connected border Simple lood-ill lgorithm void floodill4 (int x, int y, int new, int old) { int color; /* set current color to new */ getpixel (x, y, color); if (color = old) { setpixel (x, y); floodill4 (x 1, y, new, old); /* left */ floodill4 (x, y+1, new, old); /* up */ floodill4 (x+1, y, new, old); /* right */ floodill4 (x, y 1, new, old) /* down */ }} Werner Purgathofer / omputergraphik 1 33 ad ehavior of Simple lood-ill Span lood-ill lgorithm 1 2 4 3 recursion sequence floodill4 produces too high stacks (recursion!) solution: incremental horizontal fill (left to right) recursive vertical fill (first up then down) Werner Purgathofer / omputergraphik 1 34 Werner Purgathofer / omputergraphik 1 35 6
Good ehavior of Span lood-ill Span lood-ill xample 1 2 recursion sequence x Werner Purgathofer / omputergraphik 1 36 Werner Purgathofer / omputergraphik 1 37 Span lood-ill xample Span lood-ill xample 1 2 3 x 4 5 6 7 8 9 10 11 1 2 3 Werner Purgathofer / omputergraphik 1 38 Werner Purgathofer / omputergraphik 1 39 Span lood-ill xample Span lood-ill xample G 12 13 14 4 5 6 7 8 9 10 11 1 2 3 G 12 13 14 =H 4 5 6 7 8 9 10 11 1 2 3 G H Werner Purgathofer / omputergraphik 1 40 Werner Purgathofer / omputergraphik 1 41 7
Span lood-ill xample Span lood-ill xample () 4 5 6 7 8 9 10 11 1 2 3 H J 20 21 22 I 4 5 6 7 8 9 10 11 1 2 3 I J Werner Purgathofer / omputergraphik 1 42 Werner Purgathofer / omputergraphik 1 43 Span lood-ill xample Span lood-ill xample 20 21 22 1 2 3 I I J 20 21 22 1 2 3 24 25 K I K Werner Purgathofer / omputergraphik 1 44 Werner Purgathofer / omputergraphik 1 45 Span lood-ill xample Span lood-ill xample 20 21 22 1 2 3 24 25 =N 26 27 28 29 30 M L K L M N 20 21 22 1 2 3 () 24 25 31 32 33 26 27 28 29 30 M L L M N Werner Purgathofer / omputergraphik 1 46 Werner Purgathofer / omputergraphik 1 47 8
Span lood-ill xample Span lood-ill xample 20 21 22 1 2 3 24 25 31 32 33 26 27 28 29 30 34 35 L L M 20 21 22 1 2 3 24 25 31 32 33 26 27 28 29 30 34 35 36 37 L Werner Purgathofer / omputergraphik 1 48 Werner Purgathofer / omputergraphik 1 49 Span lood-ill xample 20 21 22 1 2 3 38 24 25 31 32 33 26 27 28 29 30 34 35 36 37 Werner Purgathofer / omputergraphik 1 50 finished! haracter ttributes text attributes font (e.g. ourier, rial, Times, Werner Purgathofer / omputergraphik 1 51, ) styles (regular, bold, italic, underline, ) size (32 point, 1 point = 1/72 inch) proportionally sized vs. fixed space fonts string attributes horizontal orientation alignment (left, center, right, justify) isplayed primitives generated by the raster algorithms discussed in hapter 3 have a jagged, or stairstep, appearance. isplayed primitives generated by the raster algorithms discussed in hapter 3 have a jagged, or stairstep, appearance. isplayed primitives generated by the raster algorithms discussed in hapter 3 have a jagged, or stairstep, appearance. slanted v e r t i c a l isplayed primitives generated by the raster algorithms discussed in hapter 3 have a jagged, or stairstep, appearance. Triangle and Polygon ttributes color material transparency texture surface details reflexion properties, liasing and ntialiasing what is aliasing? ['eiliæsiη] what is the reason for aliasing? what can we do against it? defined illumination produces effects Werner Purgathofer / omputergraphik 1 52 Werner Purgathofer / omputergraphik 1 53 9
What is liasing? liasing: Staircase ffect errors that are caused by the discretization of analog data to digital data Werner Purgathofer / omputergraphik 1 54 too bad resolution too few colors too few images / sec geometric errors numeric errors Werner Purgathofer / omputergraphik 1 55 Various liasing ffects liasing from too few olors artificial color borders can appear Werner Purgathofer / omputergraphik 1 56 Werner Purgathofer / omputergraphik 1 57 liasing in nimations jumping images "worming t Solutions against liasing? 1. improve the devices higher resolution more color levels faster image sequence expensive or incompatible backwards rotating wheels 2. improve the images = antialiasing postprocessing software prefiltering! Werner Purgathofer / omputergraphik 1 58 Werner Purgathofer / omputergraphik 1 59 10
Shannon Sampling Theorem a signal can only be reconstructed without information loss if the sampling frequency is at least twice the highest frequency of the signal this border frequency is called "Nyquist Limit" Shannon Sampling Theorem original signal reconstructed signal sampling rate Δ Δ Nyquist sampling interval Werner Purgathofer / omputergraphik 1 60 Werner Purgathofer / omputergraphik 1 61 ntialiasing: Nyquist Sampling requency a signal can only be reconstructed without information loss if the sampling frequency is at least twice the highest frequency of the signal Nyquist sampling frequency: f s = 2 f max Δxcycle Δx = with Δx = s cycle 1/ fmax 2 i.e. sampling interval one-half cycle interval ntialiasing Strategies supersampling straight-line segments subpixel weighting masks area sampling straight-line segments filtering techniques compensating for line-intensity differences antialiasing area boundaries (adjusting boundary pixel positions) adjusting boundary pixel intensity Werner Purgathofer / omputergraphik 1 62 Werner Purgathofer / omputergraphik 1 63 ntialiasing: Supersampling Lines 0 0 1 0 2 2 3 1 0 0 0 4 1 6 8 8 5 0 ntialiasing mathematical line 3 = max. intensity... 0 = min. intensity line of finite width 9 = max. intensity... 0 = min. intensity Werner Purgathofer / omputergraphik 1 64 Werner Purgathofer / omputergraphik 1 65 11
ntialiasing: rea Sampling Lines ntialiasing: Pixel Weighting Masks calculate the pixel coverage exactly can be done with incremental schemes 0% 0% 43% 15% 71% 84% 90% 52% 3% more weight for center subpixels must be divided by sum of weights subpixel grids can also include some neighboring pixels relative weights for a grid of 3x3 subpixels Werner Purgathofer / omputergraphik 1 66 Werner Purgathofer / omputergraphik 1 67 ntialiasing: iltering Techniques continuous overlapping weighting functions to calculate the antialiased values with integrals box filter cone filter Gaussian filter Werner Purgathofer / omputergraphik 1 68 ntialiasing: Intensity ifferences Werner Purgathofer / omputergraphik 1 69 unequal line lengths displayed with the same number of pixels in each line/row have different intensities proper antialiasing compensates for that! ntialiasing ntialiasing rea oundaries (1) alternative 1: supersampling adjusting pixel intensities along an area boundary Werner Purgathofer / omputergraphik 1 70 Werner Purgathofer / omputergraphik 1 71 12
ntialiasing rea oundaries (2) alternative 2: like midpoint line algorithm p = y y mid = [m(x k + 1) + b] (y k + 0.5) y ymid Werner Purgathofer / omputergraphik 1 72 p <0 y closer to y k p >0 y closer to y k+1 p = p +(1 m) : p<1 m closer to y k p>1 m closer to y k+1 ( and p [0,1] ) ntialiasing rea oundaries (3) p = p +(1-m) = [m(x k + 1) + b] (y k + 0.5) + (1 m) = = mx k + b y k + 0.5 = mx k + b (y k 0.5) y k p for next pixel = overlap area for current pixel p y k + 0.5 x k x k +1 Werner Purgathofer / omputergraphik 1 73 p p m 1-m 1-m m ntialiasing rea oundaries (4) ntialiasing xamples Werner Purgathofer / omputergraphik 1 74 Werner Purgathofer / omputergraphik 1 75 ntialiasing xamples Summary: ttributes of Primitives in 2 points, lines polygons, circles, ellipses & other curves (also filled) characters in 3 triangles & other polygons anti-aliasing Werner Purgathofer / omputergraphik 1 76 Werner Purgathofer / omputergraphik 1 77 13