0% found this document useful (0 votes)
887 views6 pages

Region Filling: 168 471 Computer Graphics, KKU. Lecture 7 1

There are two main approaches to region filling: seed fill and scanline fill. Seed fill works at the pixel level and includes boundary fill and flood fill algorithms, which are suitable for interactive painting. Scanline fill works at the polygon level and has better performance. Boundary fill starts inside a region and paints outward to the edge color. Flood fill replaces a specified interior color with a fill color within the 4-connected or 8-connected region.

Uploaded by

Anik
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
887 views6 pages

Region Filling: 168 471 Computer Graphics, KKU. Lecture 7 1

There are two main approaches to region filling: seed fill and scanline fill. Seed fill works at the pixel level and includes boundary fill and flood fill algorithms, which are suitable for interactive painting. Scanline fill works at the polygon level and has better performance. Boundary fill starts inside a region and paints outward to the edge color. Flood fill replaces a specified interior color with a fill color within the 4-connected or 8-connected region.

Uploaded by

Anik
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 6

Region Filling

• Seed Fill Approaches


– 2 algorithms: Boundary Fill and Flood Fill
– works at the pixel level
– suitable for interactive painting apllications
• Scanline Fill Approaches
– works at the polygon level
– better performance

168 471 Computer Graphics, KKU. Lecture


1
7
Seed Fill Algorithms: Connectedness
• 4-connected region: From a given pixel, the region
that you can get to by a series of 4 way moves (N, S,
E and W)
• 8-connected region: From a given pixel, the region
that you can get to by a series of 8 way moves (N, S,
E, W, NE, NW, SE, and SW)

4-connected 8-connected
168 471 Computer Graphics, KKU. Lecture
2
7
Boundary Fill Algorithm
• Start at a point inside a region
• Paint the interior outward to the edge
• The edge must be specified in a single color
• Fill the 4-connected or 8-connected region
• 4-connected fill is faster, but can have problems:

168 471 Computer Graphics, KKU. Lecture


3
7
Boundary Fill Algorithm (cont.)

void BoundaryFill4(int x, int y,


color newcolor, color edgecolor)
{
int current;
current = ReadPixel(x, y);
if(current != edgecolor && current != newcolor)
{
BoundaryFill4(x+1, y, newcolor, edgecolor);
BoundaryFill4(x-1, y, newcolor, edgecolor);
BoundaryFill4(x, y+1, newcolor, edgecolor);
BoundaryFill4(x, y-1, newcolor, edgecolor);
}
}
168 471 Computer Graphics, KKU. Lecture
4
7
Flood Fill Algorithm
• Used when an area defined with multiple colo
r boundaries
• Start at a point inside a region
• Replace a specified interior color (old color) wi
th fill color
• Fill the 4-connected or 8-connected region un
til all interior points being replaced

168 471 Computer Graphics, KKU. Lecture


5
7
Flood Fill Algorithm (cont.)
void FloodFill4(int x, int y, color newcolor, color oldColor)
{
if(ReadPixel(x, y) == oldColor)
{
FloodFill4(x+1, y, newcolor, oldColor);
FloodFill4(x-1, y, newcolor, oldColor);
FloodFill4(x, y+1, newcolor, oldColor);
FloodFill4(x, y-1, newcolor, oldColor);
}
}

168 471 Computer Graphics, KKU. Lecture


6
7

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy