Flood Fill (Flood fill) algorithm
Starting from a starting node to extract or fill a nearby node with a different color color, until all the nodes in the enclosing area have been processed, is to extract from a region of several connected points and other adjacent regions (or separately dyed different colors) of the classical algorithm.
It is named after the idea that the floods spread from one area to all the areas that could be reached. In GNU go and minesweeper, the Flood fill algorithm is used to calculate the areas that need to be purged.
The Flood fill algorithm accepts three parameters: the starting node, the target node feature, and the processing to be performed on the extracted object.
There are many implementations, basically explicitly or implicitly using a queue or stack.
The most common method of flood filling algorithm is to fill the neighborhood domain (regardless of the diagonal direction of the node), eight neighborhood fill method (considering the diagonal direction of the node), based on the scanning line filling method.
According to the implementation can be divided into recursive and non-recursive (based on the stack).
The simplest method is to use the recursive method of depth-first search, or the iteration of breadth-first search to realize it.
The recursive implementation-based flooding filling algorithm has a fatal disadvantage, that is, for large area fills can lead to stack overflow error,
A non-recursive flood filling algorithm is implemented based on the algorithm of scan line.
In addition to the proposed connectivity area, it can also be applied to calculate the distance from a node to the point where all other nodes may be reached. For example, to solve the problem such as walking maze.
Resources:
1. Image processing Flood fill algorithm (Flood fill algorithm)
http://blog.csdn.net/jia20003/article/details/8908464
2.Flood Fill algorithm
Http://acm.nudt.edu.cn/~twcourse/ConnectedComponentLabeling.html#a1
3.quickfill:an efficient flood fill algorithm.
Http://www.codeproject.com/Articles/6017/QuickFill-An-efficient-flood-fill-algorithm
Flood Fill (Flood fill) algorithm