Flood Fill (Flood fill) algorithm

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.