Docsity

Scanline Fill Algorithm: Performance Improvements and Data Structures, Study notes of Computer Graphics

Toggle sidebar
bg1
Scanline Fill
Peroformance Improvements
brute force: intersect all the edges with
each scanline
1) Improvement 1:
find the ymin and ymax of each edge
and intersect the edge only when it
crosses the scanline
current scanline
e3
e4
e5
e6
e1e2
2) Improvement 2:
a) only calculate the intersection of the
edge with the 1st scanline it intersects
b) calculate dx/dy
c) for subsequent scanlines, derive new
intersections as x = x + dx/dy
3) Improvement 3:
change x = x+ dx/dy to integer arithmetic
pf3
pf4

Partial preview of the text

Download Scanline Fill Algorithm: Performance Improvements and Data Structures and more Study notes Computer Graphics in PDF only on Docsity!

Peroformance Improvements brute force: intersect all the edges with each scanline

  1. Improvement 1: find the ymin and ymax of each edge and intersect the edge only when it crosses the scanline

current scanline

e

e 4

e

e e1 (^) e

  1. Improvement 2: a) only calculate the intersection of the edge with the 1st scanline it intersects b) calculate dx/dy c) for subsequent scanlines, derive new intersections as x = x + dx/dy
  2. Improvement 3: change x = x+ dx/dy to integer arithmetic

Data Structures

  1. Edge Table − keep a separate bucket for each scanline − all edges sorted by their ymin and inserted into the table − within each bucket, edges are sorted by increasing x of the ymin endpoint

A

F

E

D

C

B

EF (^) DE CD FA AB BC

Edge structure: ymax, xmin, dx/dy, next AB: 3, 6, −2, BC

Algorithm

Construct the Edge Table (ET) y = smallest y in the ET Active Edge Table (AET) = NULL for y = ymin to ymax Merge−sort ET[y] into AET by x value Fill between pairs of x in AET for each edge in AET if edge.ymax = y remove edge from AET else edge.x = edge.x + dx/dy Sort AET by x value (as needed) end scan_fill