Presentation is loading. Please wait.

Presentation is loading. Please wait.

CST 494/598 Computer Graphics Anshuman Razdan i3dea.asu.edu/razdan.

Similar presentations


Presentation on theme: "CST 494/598 Computer Graphics Anshuman Razdan i3dea.asu.edu/razdan."— Presentation transcript:

1 CST 494/598 Computer Graphics Anshuman Razdan razdan@asu.edu i3dea.asu.edu/razdan

2 A Razdan and Peter Wonka 1 Disclaimer These slides can only be used as study material for the class 470 at ASU The slides cannot be distributed or used for another purpose The slides may contain errors The slides do not contain all the information necessary to succeed in class; additional material from the book must to be studied The slides are based on a lecture from Prof. Purgathofer from the Vienna University of Technology

3

4 A Razdan and Peter Wonka 3 Color and Gray Scale color information: RGB color codes directly in frame buffer 1024 x 1024 x 24 bit/color  3 Mbyte storage color (lookup) tables less storage easy change of color table (e.g., for color coding) gray scale calculated from RGB e.g. intensity = 0.5 [min(r,g,b) + max(r,g,b)] red green blue Farbe 0 0 0 black 0 0 1 blue 0 1 0 green 0 1 1 cyan 1 0 0 red 1 0 1 magenta yellow 1 1 0 yellow 1 1 1 white

5 A Razdan and Peter Wonka 4 Color Lookup Table i j r i j g i j b i j xx xx r g b instead of: now: selected colors addressed by table index

6 A Razdan and Peter Wonka 5 Line Attributes (1) type solid, dashed, dotted,… pixel mask (raster line algorithms) width Bresenham + additional vertical (horizontal) spans width dependent on line slope line caps

7 A Razdan and Peter Wonka 6 Line Attributes (2) width thick lines as filled rectangles joining two segments: miter round bevel pen and brush options shape, size, pattern pixel mask simulation of brush strokes color

8 A Razdan and Peter Wonka 7 Area-Fill Attributes (1) fill styles hollow with color border filled with solid color filled with specific pattern or design (e.g., hatch,…)

9 A Razdan and Peter Wonka 8 Area-Fill Attributes (2) fill options edge type, width, color pattern specification through pattern tables tiling (pattern reference point) 4 0 0 4 start position pixel start position 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

10 A Razdan and Peter Wonka 9 Area-Fill Attributes (3) combination of fill pattern with background colors soft fill combination of colors antialiasing at object borders simulation of semitransparent brushes example: linear soft-fill pattern back- ground and or xor replace F...foreground color B...background color BttFtFP)1( 

11 A Razdan and Peter Wonka 10 Scan-Line Polygon-Fill Algorithm interior pixels along a scan line passing through a polygon area

12 A Razdan and Peter Wonka 11 Scan-L. Fill: Intersecting Vertices intersection points along scan lines that intersect poly- gon vertices. y: odd number of intersections y’: even number of intersections (bad) can be paired for correct interior pixel spans

13 A Razdan and Peter Wonka 12 Scan-L. Fill: Incremental Update incremental update of intersection point kk kk xx yy m      1 1 1 1   kk yy m xx kk 1 1    y x xx kk     1 slope of polygon boundary line: m (for 2 successive scanlines)

14 A Razdan and Peter Wonka 13 Scan-L. Fill: Sorted Edge Table sort all edges on smallest y-value edge entry: [max y-value, x-intercept, inverse slope] active-edge list for each scan line contains all edges crossed by that scan line incremental update consecutive intersection pairs (spans) filled

15 A Razdan and Peter Wonka 14 Sorted Edge Table: Example a polygon and its sorted edge table, with edge DC shortened by 1 unit

16 A Razdan and Peter Wonka 15 Scan-Line Fill: Active-Edge List active-edge list for - DC’ - DE - AE - AB

17 A Razdan and Peter Wonka 16 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

18 A Razdan and Peter Wonka 17 Flood-Fill Algorithm 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

19 A Razdan and Peter Wonka 18 Flood-Fill: Definition of Boundary area must be distinguishable from boundaries example: area defined within multiple color boundaries

20 A Razdan and Peter Wonka 19 Flood-Fill: Connectedness Definition: 4-connected means, that a connection is only valid in these 4 directions Definition: 8-connected means, that a connection is only valid in these 8 directions

21 A Razdan and Peter Wonka 20 Example for 4- and 8-connected a 4-connected areaan 8-connected area a 4-connected area has an 8-connected border an 8-connected area has a 4-connected border

22 A Razdan and Peter Wonka 21 Simple Flood-Fill Algorithm

23 A Razdan and Peter Wonka 22 Bad Behaviour of Simple Flood-Fill 1 2 4 3 recursion sequence

24 A Razdan and Peter Wonka 23 Span Flood-Fill Algorithm floodFill4 produces too high stacks (recursion!) solution: incremental horizontal fill (left to right) recursive vertical fill (first up then down)

25 A Razdan and Peter Wonka 24 Good Behaviour of Span Flood-Fill 1 2 recursion sequence

26 A Razdan and Peter Wonka 25 Span Flood-Fill Example x

27 A Razdan and Peter Wonka 26 Span Flood-Fill Example s2 123 s1

28 A Razdan and Peter Wonka 27 Span Flood-Fill Example s5s4 4567891011 123 s2 s1 s3

29 A Razdan and Peter Wonka 28 Span Flood-Fill Example s5 121314 s4 4567891011 s3 123 s2 s1

30 A Razdan and Peter Wonka 29 Span Flood-Fill Example 121314 s4 4567891011 s3 123 s2 s1 16171815

31 A Razdan and Peter Wonka 30 Span Flood-Fill Example 15161718 12131419 4567891011 s3 123 s2 s1

32 A Razdan and Peter Wonka 31 Span Flood-Fill Example 121314 s4 4567891011 202122123 s2 s3s1 15161718 19

33 A Razdan and Peter Wonka 32 Span Flood-Fill Example 121314 234567891011 202122123 s2 s3s1 15161718 19

34 A Razdan and Peter Wonka 33 Span Flood-Fill Example 121314 234567891011 202122123 s2 2425 s1 s3 15161718 19

35 A Razdan and Peter Wonka 34 Span Flood-Fill Example 121314 234567891011 202122123 s2 2425 s1=s5 2627282930 s4s3 15161718 19

36 A Razdan and Peter Wonka 35 Span Flood-Fill Example 121314 234567891011 202122123 s2 2425313233 2627282930 s4s3 15161718 19

37 A Razdan and Peter Wonka 36 Span Flood-Fill Example 121314 234567891011 202122123 s2 2425313233 2627282930 3435 s3 15161718 19

38 A Razdan and Peter Wonka 37 Span Flood-Fill Example 121314 234567891011 202122123 s2 2425313233 2627282930 34353637 15161718 19

39 A Razdan and Peter Wonka 38 Span Flood-Fill Example 121314 234567891011 20212212338 2425313233 2627282930 34353637 15161718 19

40 A Razdan and Peter Wonka 39 text attributes font (e.g. Courier, Arial, Times, Roman, …) styles (regular, bold, italic, underline,…) size (32 point, 1 point = 1/72 inch) proportionally sized vs. fixed space fonts string attributes orientation alignment (left, center, right, justify) Character Attributes verticalvertical horizontal slanted Displayed primitives generated by the raster algorithms discussed in Chapter 3 have a jagged, or stairstep, appearance.

41 A Razdan and Peter Wonka 40 Antialiasing what is aliasing? what is the reason for aliasing? what can we do against it?

42 A Razdan and Peter Wonka 41 What is Aliasing? not enough resolution not enough colors not enough images / sec geometric errors numeric errors errors that are caused by the discretization of analog data to digital data

43 A Razdan and Peter Wonka 42 Aliasing: Staircase Effect

44 A Razdan and Peter Wonka 43 Various Aliasing Effects

45 A Razdan and Peter Wonka 44 Aliasing from too few Colors artificial color borders can appear

46 A Razdan and Peter Wonka 45 Aliasing in Animations jumping images "worming“ backwards rotating wheels

47 A Razdan and Peter Wonka 46 Backwards Rotating Wheels

48 A Razdan and Peter Wonka 47 Solutions against Aliasing? 1. improve the devices higher resolution more color levels faster image sequence 2. improve the images postprocessing antialiasing ! expensive or incompatible software

49 A Razdan and Peter Wonka 48 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"

50 A Razdan and Peter Wonka 49 Shannon Sampling Theorem Nyquist sampling interval sampling rate  original signal reconstructed signal 

51 A Razdan and Peter Wonka 50 Antialiasing: Nyquist Sampling Frequency a signal can only be reconstructed without information loss if the sampling frequency is at least twice the highest frequency of the signal maxcycle /1x with 2 f x x cycle s    i.e. sampling interval  one-half cycle interval max 2ff s  Nyquist sampling frequency:

52 A Razdan and Peter Wonka 51 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 Antialiasing Strategies

53 A Razdan and Peter Wonka 52 Antialiasing: Supersampling Lines 001 022 310 004 168 850 3 = max. intensity... 0 = min. intensity 9 = max. intensity... 0 = min. intensity thin line line of finite width

54 A Razdan and Peter Wonka 53 Antialiasing

55 A Razdan and Peter Wonka 54 Antialiasing: Area Sampling Lines calculate the pixel coverage exactly can be done with incremental schemes 0%0%0%0% 0%0%0%0%43 157184 9052 3%3%3%3%

56 A Razdan and Peter Wonka 55 Antialiasing: Pixel Weighting Masks relative weights for a grid of 3x3 subpixels more weight for center subpixels must be divided by sum of weights subpixel grids can also include some neighboring pixels

57 A Razdan and Peter Wonka 56 Antialiasing: Filtering Techniques box filter cone filter Gaussian filter continuous overlapping weighting functions to calculate the antialiased values with integrals

58 A Razdan and Peter Wonka 57 Antialiasing: Compensating for Intensity Differences unequal line lengths displayed with the same number of pixels in each line/row have different intensities proper antialiasing compensates for that!

59 A Razdan and Peter Wonka 58 Antialiasing

60 A Razdan and Peter Wonka 59 Antialiasing Area Boundaries (1) adjusting pixel intensities along an area boundary alternative 1: supersampling

61 A Razdan and Peter Wonka 60 Antialiasing Area Boundaries (2) alternative 2: like midpoint line algorithm p´ = y  y mid = [m(x k + 1) + b]  (y k + 0.5) 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] ) y y mid Note: We add (1-m) so that the decision parameter p = area covered by polygon!

62 A Razdan and Peter Wonka 61 Antialiasing Area Boundaries (3) p = p´+(1-m) = [m(x k + 1) + b]  (y k + 0.5) + (1  m) = mx k + b  y k + 0.5 = xkxk x k +1 ykyk y k + 0.5 p for next pixel = overlap area for current pixel p´ p = p´-m+1 = p´+(1-m) m p´-m

63 A Razdan and Peter Wonka 62 Antialiasing Examples

64 A Razdan and Peter Wonka 63 Antialiasing Examples

65 A Razdan and Peter Wonka 64 Summary: Attributes of Primitives color and greyscale line attributes area fill attributes character attributes antialiasing aliasing effects reasons for aliasing antialiasing strategies


Download ppt "CST 494/598 Computer Graphics Anshuman Razdan i3dea.asu.edu/razdan."

Similar presentations


Ads by Google