I have been looking for a Pythonic implementation that returns a 4 and 8-connected path where True is the 4 or 8 adjacency and False is not, given a binary image and x and y coordinates of a pixel. As an example, here's the binary image:
[[ True False False False ]
[False True True True ]
[False True True False ]]
I need to find a way to return a binary image that represents all the pixels belonging to the 4 or 8-connected path starting from a given pixel.
As an example, given the image above and x, y coordinates (1,1) the 4-connected path should be:
[[ True False False False ]
[False False False False ]
[False False False False ]]
Given x, y coordinates (3,2), it would be:
[[ False False False False ]
[False True True True ]
[False True True False ]]
What are some of the ways to do it in Python?