Dr' Scott Schaefer - PowerPoint PPT Presentation

1 / 63
About This Presentation
Title:

Dr' Scott Schaefer

Description:

with line drawing algo. 10 /63. General Polygons Basic Idea. Intersect scan lines with edges ... with line drawing algo. Use coherence to speed up. 11 /63 ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 64
Provided by: symo5
Category:
Tags: algo | schaefer | scott

less

Transcript and Presenter's Notes

Title: Dr' Scott Schaefer


1
Scan Conversion of Polygons
  • Dr. Scott Schaefer

2
Drawing Rectangles
  • Which pixels should be filled?

3
Drawing Rectangles
  • Is this correct?

4
Drawing Rectangles
  • What if two rectangles overlap?

5
Drawing Rectangles
  • Is this correct?

6
Drawing Rectangles
Overlap!!!
  • Is this correct?

7
Drawing Rectangles
  • Solution Exclude pixels on top and right

8
Drawing Rectangles
  • Artifacts are possible

9
General Polygons Basic Idea
  • Intersect scan lines with edges
  • Find ranges along x
  • Fill interior of those
  • ranges
  • Dont fill top/right
  • Edges may NOT match
  • with line drawing algo

10
General Polygons Basic Idea
Use coherence to speed up
  • Intersect scan lines with edges
  • Find ranges along x
  • Fill interior of those
  • ranges
  • Dont fill top/right
  • Edges may NOT match
  • with line drawing algo

11
General Polygons Basic Idea
Use coherence to speed up
  • Intersect scan lines with edges
  • Find ranges along x
  • Fill interior of those
  • ranges

Edges intersection one scan line are mostly same
as those intersecting previous scan line
12
General Polygons Basic Idea
Use coherence to speed up
  • Intersect scan lines with edges
  • Find ranges along x
  • Fill interior of those
  • ranges

The x-value of an intersection with one scan line
is close to the intersection with the previous one
13
General Polygons Data Structures
  • Active Edge Table

Store a linked-list per scan-line. Insert edges
into table at scan-line associated with lowest
end-point.
Scan Lines
Edges
14
General Polygons Data Structures
  • Active Edge List

List of all edges intersecting current scan-line
sorted by their x-values
Edges
15
General Polygons Data Structures
  • Edge

maxY highest y-value currentX x-value of
end-point with lowest y-value xIncr 1 / slope
Edge
mazY
currentX
xIncr
16
General Polygons Data Structures
  • Edge

maxY highest y-value currentX x-value of
end-point with lowest y-value xIncr 1 / slope
Edge
mazY
currentX
xIncr
Horizontal edges will not be used!!!
17
General Polygons Algorithm
  • line 0
  • While (line lt height )
  • Add edges to Active Edge List from Active Edge
    Table starting at line
  • Remove edges that end at line
  • Fill pixels
  • Increment x-values on edges in Active Edge List
  • Increment line

18
General Polygons Example
C
Active Edge Table
B
D
G
Active Edge List
E
F
A
19
General Polygons Example
C
Active Edge Table
B
D
G
AB
AG
Active Edge List
E
F
A
20
General Polygons Example
C
Active Edge Table
B
D
G
FG
ED
AB
AG
Active Edge List
E
F
A
21
General Polygons Example
C
Active Edge Table
B
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
A
22
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
A
23
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
AG
AB
A
maxY
currentX
xIncr
24
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
AG
AB
ED
FG
A
maxY
currentX
xIncr
25
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
AG
AB
ED
FG
A
maxY
currentX
xIncr
26
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
AG
AB
ED
FG
A
maxY
currentX
xIncr
27
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
AG
AB
ED
FG
A
maxY
currentX
xIncr
28
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
AG
AB
ED
FG
A
maxY
currentX
xIncr
29
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
AB
ED
A
maxY
currentX
xIncr
30
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
AB
ED
A
maxY
currentX
xIncr
31
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
AB
ED
A
maxY
currentX
xIncr
32
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
AB
ED
A
maxY
currentX
xIncr
33
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
AB
ED
CD
A
maxY
currentX
xIncr
34
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
AB
ED
CD
A
maxY
currentX
xIncr
35
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
AB
CD
A
maxY
currentX
xIncr
36
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
AB
CD
A
maxY
currentX
xIncr
37
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
BC
CD
AB
A
maxY
currentX
xIncr
38
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
BC
CD
AB
A
maxY
currentX
xIncr
39
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
BC
CD
A
maxY
currentX
xIncr
40
General Polygons Example
C
Active Edge Table
B
BC
D
CD
G
FG
ED
AB
AG
Active Edge List
E
F
BC
CD
A
maxY
currentX
xIncr
41
General Polygons Problems
  • Sliver polygons may not be drawn correctly
  • No simple solution
  • Long, thin triangles
  • cause problems
  • Want triangles with
  • good aspect ratio
  • (close to equilateral)

42
Boundary Fill
  • Start with drawn outline of a polygon and an
    interior point
  • Recursively recolor outward from that point
  • If neighbor different, then recolor and recur
  • Everything within the boundary is changed to that
    color

43
Boundary Fill
  • How to define a neighbor?

8-connected
4-connected
44
Boundary Fill Example
45
Boundary Fill Example
46
Boundary Fill Example
47
Boundary Fill Example
48
Boundary Fill Example
49
Boundary Fill Example
50
Flood Fill
  • Start with a point
  • Define color under that point as the interior
    color
  • Recursively recolor outward from that point
  • If neighbor is interior color, then recolor and
    recur
  • Contiguous regions of the same color are recolored

51
Flood Fill Example
52
Flood Fill Example
53
Flood Fill Example
54
Flood Fill Example
55
Flood Fill Example
56
Flood Fill Example
57
Flood Fill Example
58
Flood Fill Example
59
Flood Fill Example
60
Flood Fill Example
61
Flood Fill Example
62
Flood Fill Example
63
Flood Fill Example
Write a Comment
User Comments (0)
About PowerShow.com