Science Fair Projects Ideas - Flood fill

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

Flood fill

Flood fill, also called seed fill, is a recursive algorithm that determines connected regions in a multi-dimensional array. It is used in the "bucket" fill tool of paint programs to determine which part of a bitmap to fill with color, in Tetris implementations for determining what falls and what doesn't, and in Puyo Puyo and Magical Drop implementations for determining what pieces are cleared.

Flood fill takes three parameters: start element, source symbol, and destination symbol. It changes every element in the array that is connected to the start element and that contains the source symbol to the destination symbol. Normally, a helper function wraps around flood fill and initializes the source symbol from the symbol under the provided point.

  1. If the start element does not contain the source symbol, or if the source symbol equals the destination symbol, stop.
  2. Look to the left of the start element for more elements that match the source symbol. Stop when you find the edge of the array or an element not containing the source symbol.
  3. Look to the right of the current element for more elements that match the source symbol.
  4. Fill this horizontal line with the destination symbol.
  5. For each element above or below (or in 3D, in front of or behind) an element in the horizontal line just filled, run flood fill on that element, keeping source and destination symbol the same.

Flood fill example in C

Adapting the algorithm to use an additional array to store the shape of the region allows generalization to cover "fuzzy" flood filling, where an element can differ by up to a specified threshold from the source symbol, and the edges of the filled region blend somewhat smoothly with the not-filled region.

Last updated: 05-07-2005 04:53:19
10-26-2009 08:16:03
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice