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
-
Convert a vector into a number
613 Solvers
-
Compute the dilation of a binary image
52 Solvers
-
Minimum Distance Point to Segment
61 Solvers
-
Convert given decimal number to binary number.
2263 Solvers
-
Find out sum and carry of Binary adder
1681 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!