CG3 - Fill Area Primitives
CG3 - Fill Area Primitives
Intro to Computer
Graphics
Filling 2D Shapes
Solid Fill
Pattern Fill
Texture Fill
requirements
Digital images
Original Image
Filled outlines
The inside of a
circle of radius R
E.g.
Edge list
Ordered edges
Edge list
Edge list
Filled shape
Fill Options
How
Solid Fill
Pattern Fill
Texture Fill
Seed Fill
Approach
Seed point
Move outwards
to neighbors
Seed Fill
Basic algorithm
select seed pixel
initialize a fill list to contain seed pixel
while (fill list not empty) {
pixel get next pixel from fill list
setPixel(pixel)
for (each of the pixels neighbors) {
if (neighbor is inside region AND neighbor not set)
add neighbor to fill list
}
}
Magnified area
Original boundary
Boundary fill
Flood fill
Boundary Fill
Fill condition
Seed pixel
Boundary pixel
Flood Fill
Fill condition
Seed pixel
Improving Performance
Problems
Slow
Neighbor coherence
Span coherence
Scan-line coherence
Seed point
Seed point
Determine spans of pixels in the rows above and below the current
row that are connected to the current span
Add the left-most pixel of these spans to the fill list
(Xmax, Ymax)
(Xmin, Ymin)
(Xmax, Ymax)
(Xmin, Ymin)
The line segments must form a closed shape (i.e. the boundary must
connected)
General polygons
Determine the winding number (i.e. the number of times the edge
winds around the point in either a clockwise or counterclockwise
direction)
Inside-Outside Tests
Even-odd parity
Non-zero winding
Inside-Outside Tests
Standard polygons
Shared Vertices
If the line drawn for the fill rule intersects a vertex, the
edge crossing would be counted twice
1.
If the vertex is between two upwards or two downwards edges, the line
pierces the edge
Preprocess edge vertices to make sure that none of them fall on a scan line
Problems
2. Efficiency
Raster-Based Filling
Fill spans of pixels inside the polygon along each horizontal scan
line
Raster-Based Filling
Raster-Based Filling
Raster-Based Filling