Problem 46028. Paint it black!
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
-
4 Comments
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).
Solution Comments
Show commentsProblem Recent Solvers2
Suggested Problems
-
586 Solvers
-
152 Solvers
-
43 Solvers
-
Find the sides of an isosceles triangle when given its area and height from its base to apex
1911 Solvers
-
Determine RSA keys (public and private) given two prime number character strings (p and q)
13 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!