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.

 

<< PreviousWord BrowserNext >>
fundamentalism
fucking ml
full disclosure
feminist theology
fsk
fictional guidebook
freeware
flat earth
persian language
farsi
frances abington
firewire
finite field
franchising
feynman diagram
food writing
futurama
final fantasy 3
francesco sforza
folk dance
fyodor dostoevsky
faith healing
furry
fritz lang
food and drug administration
field extension
flood fill example in c
francis of assisi
frottage
first council of constantinople
fourth council of constantinople
friedrich hayek
gun
fred reed
fred brooks
factoid
figured bass
fashion
fourier transform
fat man
false claims act
u.s. false claims law (in depth)
fantastic four
filtration