Skip to content
crowell edited this page Sep 27, 2012 · 1 revision

Flood Fill Algorithm

Taken mostly from a Breadth First Search of the image

  1. Create Identically sized "background" image filled with WHITE
  2. Select Sample color BG from given point.
  3. Add point from selected color to queue
  4. While the Queue isn't empty
    1. De-queue item P
    2. Add neighboring WHITE points to queue (Up, Left, Right, Down) if Color is BG in image
    3. Color Neighboring WHITE points GRAY
    4. Color pixel P to HOT-PINK

Here, the mask will have a white color where items are, and a hot-pink color where the background is.

Clone this wiki locally