Flood fill is the algorithm used by bucket-fill tools in many image editors. The idea is that all connected pixels with the input color should have it changed to an output color starting at a pixel P = (x,y). Your task is to implement this algorithm replacing all colors within some tolerance (distance) from the input color with black.
For instance:
if the input_color=9, tolerance = 0, and P=[1,1], then the following grayscale image,
9 9 9 2 9 9 9 9 2 9 2 2 2 9 9 9 9 9 9 9
becomes,
0 0 0 2 9 0 0 0 2 9 2 2 2 9 9 9 9 9 9 9
Assume that all pixels have 4-neighborhoods. And use the Manhattan distance to decide if a color, a 1xn vector, is within tolerance.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers2
Suggested Problems
-
268 Solvers
-
Change a specific color in an image
74 Solvers
-
5874 Solvers
-
134 Solvers
-
Predicting life and death of a memory-less light bulb
334 Solvers
More from this Author5
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Really fun. Anti-cheat is brilliant.
Thank you, Jeremy. I'm glad you liked it.
I get
> Python Error: TypeError: Strings must be encoded before hashing
from the test suite; could this be fixed?
In addition, the file "concordorthophoto.png" used in one of the tests does not exist (anymore).