Presentation is loading. Please wait.

Presentation is loading. Please wait.

College of Computer and Information Science, Northeastern UniversityApril 17, 20151 CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 9.

Similar presentations


Presentation on theme: "College of Computer and Information Science, Northeastern UniversityApril 17, 20151 CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 9."— Presentation transcript:

1 College of Computer and Information Science, Northeastern UniversityApril 17, 20151 CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 9 – January 26, 2009

2 College of Computer and Information Science, Northeastern UniversityApril 17, 20152 Today’s Topics Fill: Boundary Fill vs. Polygon Fill 2D Polygon Fill

3 College of Computer and Information Science, Northeastern UniversityApril 17, 20153 Scan Line Polygon Fill

4 College of Computer and Information Science, Northeastern UniversityApril 17, 20154 Parity Check Draw a horizontal half-line from P to the right. Count the number of times the half-line crosses an edge. 1in 4out 7in

5 College of Computer and Information Science, Northeastern UniversityApril 17, 20155 Polygon Data Structure edges xminymax1/m  168/4  (1, 2) (9, 6) xmin = x value at lowest y ymax = highest y Why 1/m? If y = mx + b, x = (y-b)/m. x at y+1 = (y+1-b)/m = (y-b)/m + 1/m.

6 Polygon Data Structure Edge Table (ET) has a list of edges for each scan line. e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 0 5 10 13 12 11 10  e6 9 8 7  e4  e5 6  e3  e7  e8 5 4 3 2 1  e2  e1  e11 0  e10  e9

7 College of Computer and Information Science, Northeastern UniversityApril 17, 20157 Preprocessing the edges count twice, once for each edge chop lowest pixel to only count once delete horizontal edges For a closed polygon, there should be an even number of crossings at each scan line. We fill between each successive pair.

8 Polygon Data Structure after preprocessing Edge Table (ET) has a list of edges for each scan line. e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 0 5 10 13 12 11 10  e6 9 8 7  e4  e5 6  e3  e7  e8 5 4 3 2 1  e2  e1  e11 0  e10  e9 e11 7  e3  e4  e5 6  e7  e8 11  e6 10

9 College of Computer and Information Science, Northeastern UniversityApril 17, 20159 The Algorithm 1.Start with smallest nonempty y value in ET. 2.Initialize SLB (Scan Line Bucket) to nil. 3.While current y  top y value: a.Merge y bucket from ET into SLB; sort on xmin. b.Fill pixels between rounded pairs of x values in SLB. c.Remove edges from SLB whose ytop = current y. d.Increment xmin by 1/m for edges in SLB. e.Increment y by 1.

10 Running the Algorithm e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 0 5 10 13 ET 13 12 11  e6 10 9 8 7  e3  e4  e5 6  e7  e8 5 4 3 2 1  e2  e11 0  e10  e9 xminymax1/m e226-2/5 e31/3 121/3 e4412-2/5 e54130 e66 2/313-4/3 e71010-1/2 e81082 e91183/8 e10114-3/4 e11642/3 5 0 10 15

11 College of Computer and Information Science, Northeastern UniversityApril 17, 201511 Running the Algorithm e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 0 5 10 13 5 0 10 15 y=0 SCB  114-3/4  1183/8  e9 e10 10 1/4 11 3/8

12 College of Computer and Information Science, Northeastern UniversityApril 17, 201512 Running the Algorithm e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 0 5 10 13 5 0 10 15 y=1 SLB  26-2/5  642/3  e11 e2 1 3/5 10 1/44-3/4  11 3/8 83/8  e9 e10 6 2/3 9 1/2 11 6/8

13 College of Computer and Information Science, Northeastern UniversityApril 17, 201513 Running the Algorithm e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 0 5 10 13 5 0 1015 y=2 SLB  1 3/56-2/5  6 2/342/3  e11 e2 9 1/24-3/4  11 6/883/8  e9 e10 12 1/8 8 3/4 7 1/3 1 1/5

14 College of Computer and Information Science, Northeastern UniversityApril 17, 201514 Running the Algorithm e3 e4 e5 e6 e7 e8 e9 e10 0 5 10 13 5 0 1015 y=3 SLB  1 1/56-2/5  7 1/342/3  e11 e2 8 3/44-3/4  12 1/883/8  e9 e10 12 4/8 8 8 4/5 e11e2

15 College of Computer and Information Science, Northeastern UniversityApril 17, 201515 Running the Algorithm e3 e4 e5 e6 e7 e8 e10 0 5 10 13 5 0 1015 y=4 SLB  4/56-2/5  842/3  e11 e2 84-3/4  12 4/883/8  e9 e10 e11e2 e9 Remove these edges.

16 College of Computer and Information Science, Northeastern UniversityApril 17, 201516 Running the Algorithm e3 e4 e5 e6 e7 e8 0 5 10 13 5 0 1015 y=4 SLB  4/56-2/5  e2 12 4/883/8  e9 12 7/8 2/5 e2e11 e10 e9 e11 and e10 are removed.

17 College of Computer and Information Science, Northeastern UniversityApril 17, 201517 Running the Algorithm e3 e4 e5 e6 e7 e8 0 5 10 13 5 0 1015 y=5 SLB  2/56-2/5  e2 12 7/883/8  e9 13 2/8 0 e2e11 e10 e9

18 College of Computer and Information Science, Northeastern UniversityApril 17, 201518 Running the Algorithm e3 e4 e5 e6 e7 e8 0 5 10 13 5 0 1015 y=6 SLB  06-2/5  e2 10 -1/2  e7 e2e11 e10 e9 Remove this edge. 1082  e8 13 2/883/8  e9 9 1/2 12 13 5/8

19 Running the Algorithm e3 e4 e5 e6 e7 e8 0 5 10 13 5 0 1015 y=7 SLB  4130  e5 9 1/210-1/2  e7 e2e11 e10 e9 1282  e8 13 5/883/8  e9 Add these edges. 412-2/5  e4 1/3121/3  e3


Download ppt "College of Computer and Information Science, Northeastern UniversityApril 17, 20151 CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 9."

Similar presentations


Ads by Google