This is an implementation of flood fill on a PNG image using both breadth-first-search (BFS) and depth-first-search (DFS). A point on the image is first selected as our starting point, then a pattern will fill its adjacent regions that share similar color. A demo of borderColorPicker (1) and transformColorPicker (2) is presented below.
BFS border | DFS border |
---|---|
![]() |
![]() |
BFS transform | DFS transform |
---|---|
![]() |
![]() |
(1) borderColorPicker - borders around the edges of regions will be colored, leaving internal pixels unchanged.
(2) transformColorPicker - patterns from another PNG image get transformed into regions in the current PNG image.
Skeleton code and structures are provided by Prof. Cinda K. Heeren as part of a course on data structure and algorithm in University of British Columbia (UBC).
Raw source images are cited here:
pikachu image
dog image
rainbow image