Filling regions in raster images is the term given to the problem of extracting a connected region (that contains some preselected seed pixel) and filling it with some color. A connected region is formally defined as the collection of all pixels that are in the transitive closure of a pixel-connectivity operator that is applied to the seed. For example, the 4-pixel-connectivity operator selects all pixels that are (spatially) 4-connected to the pixel operand, and have the same color. This problem can be solved relatively easily if the fill color is distinguishable so that every pixel, once colored (i.e. flagged OLD) will not be considered again. In binary images, the fill “color” is usually a binary pattern and therefore, a “colored” pixel may still have its previous (e.g., black or white) color. This fact makes the problem non-trivial.
In this paper, a region to be filled is represented as a connected directed a-cyclic planar graph in which nodes are regular regions (defined below) that are easy to handle. An arc connects a regular region to its neighbor below which shares a common horizontal sub-boundary. Based on this abstract representation of a region, a formulation of the filling problem is developed as a variant of graph traversing. The difficulties imposed by filling with a binary pattern, and the avoidance of an explicit description of the graph are explored and a solution is presented. This solution utilizes the frame buffer (that is used to display the image) for improved efficiency of a graph traversal algorithm.
This method turns out to be similar to [Lieberman-78], that is shown here to be incorrect. The complexity of the new algorithm is 0(N*L+ N*Log N), compared to 0(N*L*Log N) there, where N is the number of nodes in the graph and L is the average composite degree of each node. A proof of correctness for the new algorithm is given too.
[1]
Donald Ervin Knuth,et al.
The Art of Computer Programming
,
1968
.
[2]
Claude Berge,et al.
Graphs and Hypergraphs
,
2021,
Clustering.
[3]
Alfred V. Aho,et al.
The Design and Analysis of Computer Algorithms
,
1974
.
[4]
Alan Kay,et al.
Microelectronics and the Personal Computer
,
1977
.
[5]
John V. Guttag,et al.
Abstract data types and the development of data structures
,
1977,
CACM.
[6]
Henry Lieberman.
How to color in a coloring book
,
1978,
SIGGRAPH '78.
[7]
Alvy Ray Smith,et al.
Tint fill
,
1979,
SIGGRAPH.