Presentation is loading. Please wait.

Presentation is loading. Please wait.

Bresenham’s Midpoint Algorithm CS5600 Computer Graphics Rich Riesenfeld Spring 2006 Lecture Set 1.

Similar presentations


Presentation on theme: "Bresenham’s Midpoint Algorithm CS5600 Computer Graphics Rich Riesenfeld Spring 2006 Lecture Set 1."— Presentation transcript:

1

2 Bresenham’s Midpoint Algorithm CS5600 Computer Graphics Rich Riesenfeld Spring 2006 Lecture Set 1

3 Spring 2006CS 56002 Line Characterizations Explicit: Implicit: Constant slope: Constant derivative:

4 Spring 2006CS 56003 Line Characterizations - 2 Parametric: where, Intersection of 2 planes Shortest path between 2 points Convex hull of 2 discrete points

5 Spring 2006CS 56004 Discrete Lines Lines vs. Line Segments What is a discrete line segment? –This is a relatively recent problem –How to generate a discrete line?

6 Spring 2006CS 56005 “Good” Discrete Line - 1 No gaps in adjacent pixels Pixels close to ideal line Consistent choices; same pixels in same situations

7 Spring 2006CS 56006 “Good” Discrete Line - 2 Smooth looking Even brightness in all orientations Same line for as for Double pixels stacked up?

8 Spring 2006CS 56007 Incremental Fn Eval Recall Characteristics –Fast –Cumulative Error Need to define

9 Spring 2006CS 56008 Meeting Bresenham Criteria

10 Spring 2006CS 56009 Case 1: Translate to Origin

11 Spring 2006CS 560010 Case 0: Trivial Situations Do not need Bresenham

12 Spring 2006CS 560011 Case 1: Translate to Origin Need only consider lines emanating from the origin.

13 Spring 2006CS 560012 Case 2: Flip about x-axis

14 Spring 2006CS 560013 Case 2: Flip about x-axis

15 Spring 2006CS 560014 How do slopes relate?

16 Spring 2006CS 560015 How do slopes relate? i.e.,

17 Spring 2006CS 560016 Case 3: Flip about line y = x

18 Spring 2006CS 560017 Case 3: Flip about line y = x

19 Spring 2006CS 560018 Case 3: m′ = ?

20 Spring 2006CS 560019 Line segment in first octant with 0 < m < 1 Let us proceed Restricted Form

21 Spring 2006CS 560020 Two Line Equations Explicit: Implicit: Define: Hence,

22 Spring 2006CS 560021 From previous We have, Hence,

23 Spring 2006CS 560022 Relating Explicit to Implicit Eq’s Recall, Or, where,

24 Spring 2006CS 560023 Investigate Sign of F Verify that Look at extreme values of y above line below line on line

25 Spring 2006CS 560024 The Picture above line below line

26 Spring 2006CS 560025 Key to Bresenham Algorithm “Reasonable assumptions” have reduced the problem to making a binary choice at each pixel: (Previous) NE (next) E (next)

27 Spring 2006CS 560026 Decision Variable d (logical) Define a logical decision variable d – linear in form – incrementally updated (with addition) – tells us whether to go E or NE

28 Spring 2006CS 560027 The Picture ideal line midpoint E NE previous Q M

29 Spring 2006CS 560028 The Picture (again) ideal line E NE previous Q midpoint M

30 Spring 2006CS 560029 Observe the relationships Suppose Q is above M, as before. Then, M is below the line So, means line is above M, Need to move NE, increase y value

31 Spring 2006CS 560030 The Picture (again) ideal line midpoint E NE previous Q

32 Spring 2006CS 560031 Observe the relationships Suppose Q is below M, as before. Then F (M) < 0, implies M is above the line So, F (M) < 0, means line is below M, Need to move to E; don’t increase y

33 Spring 2006CS 560032 M = Midpoint = : Want to evaluate at M Will use an incr decision var d Let,

34 Spring 2006CS 560033 How will d be used? Recall, Therefore,

35 Spring 2006CS 560034 Case 1: Suppose E is chosen Recall...

36 Spring 2006CS 560035... Case 1: Suppose E is chosen

37 Spring 2006CS 560036 Review of Explicit to Implicit Recall, Or, where,

38 Spring 2006CS 560037 Case 1:.

39 Spring 2006CS 560038 Case 2: Suppose NE chosen Recall...

40 Spring 2006CS 560039 Case 2: Suppose NE...

41 Spring 2006CS 560040 Case 2:.

42 Spring 2006CS 560041 Case 2:.

43 Spring 2006CS 560042 Summary At each step of the procedure, we must choose between moving E or NE based on the sign of the decision variable d Then update according to

44 Spring 2006CS 560043 What is initial value of d ? First point is First midpoint is What is initial midpoint value?

45 Spring 2006CS 560044 What is initial value of d ?

46 Spring 2006CS 560045 What is initial value of d ? Hence,

47 Spring 2006CS 560046 What is initial value of d ? Hence,

48 Spring 2006CS 560047 What Does “2 x ” Do ? Has the same 0-set Changes the slope of the plane Rotates plane about the 0-set line

49 Spring 2006CS 560048 What is initial value of d ?

50 Spring 2006CS 560049 What is initial value of d ?

51 Spring 2006CS 560050 More Summary Initial value Case 1: Case 2:

52 Spring 2006CS 560051 More Summary Choose

53 Spring 2006CS 560052 Example Line end points: Deltas:

54 Spring 2006CS 560053 Graph 13 12 11 10 9 8 7 6 4 5 6 7 8 9 10 11

55 Spring 2006CS 560054 Example ( dx = 4; dy = 3 ) Initial value of

56 Spring 2006CS 560055 Graph 13 12 11 10 9 8 7 6 4 5 6 7 8 9 10 11

57 Spring 2006CS 560056 Example ( dx = 4; dy = 3 ) Update value of d

58 Spring 2006CS 560057 Example ( dx = 4; dy = 3 ) -2 Update value of d Last move was NE, so 2d(6,9) = 2d(y - dy) = 2(4 - 3) = - 2 d = 2 – 2 = 0  E

59 Spring 2006CS 560058 Graph 13 12 11 10 9 8 7 6 4 5 6 7 8 9 10 11

60 Spring 2006CS 560059 Example ( dx = 4; dy = 3 ) Previous move was E

61 Spring 2006CS 560060 Graph 13 12 11 10 9 8 7 6 4 5 6 7 8 9 10 11

62 Spring 2006CS 560061 Example ( dx = 4; dy = 3 ) Previous move was

63 Spring 2006CS 560062 Graph 13 12 11 10 9 8 7 6 4 5 6 7 8 9 10 11

64 Spring 2006CS 560063 Graph 13 12 11 10 9 8 7 6 4 5 6 7 8 9 10 11

65 Spring 2006CS 560064 Graph 13 12 11 10 9 8 7 6 4 5 6 7 8 9 10 11

66 Spring 2006CS 560065 More Raster Line Issues Fat lines with multiple pixel width Symmetric lines How should end pt geometry look? Generating curves, e.g., circles, etc. Jaggies, staircase effect, aliasing...

67 Spring 2006CS 560066 Pixel Space

68 Example

69

70 Spring 2006CS 560069 Bresenham Circles

71 Spring 2006CS 560070 The End Bresenham’s Algorithm Lecture Set 1


Download ppt "Bresenham’s Midpoint Algorithm CS5600 Computer Graphics Rich Riesenfeld Spring 2006 Lecture Set 1."

Similar presentations


Ads by Google