Flood Fill - Algorithmix/Picasso GitHub Wiki
Flood Fill Algorithm
Taken mostly from a Breadth First Search of the image
- Create Identically sized "background" image filled with
WHITE - Select Sample color
BGfrom given point. - Add point from selected color to queue
- While the Queue isn't empty
- De-queue item
P - Add neighboring
WHITEpoints to queue (Up, Left, Right, Down) if Color isBGin image - Color Neighboring
WHITEpointsGRAY - Color pixel
PtoHOT-PINK
- De-queue item
Here, the mask will have a white color where items are, and a hot-pink color where the background is.