I have an image represented as a 2D array. I would like to get the coordinates of pixels over a line from point 1 to point 2.
For example, let's say I have an image with size 5x4 like in the image below. And I have a line from point 1 at coordinates (0, 2) to point 2 at (4, 1). Like the red line on the image below:
So here I would like to get the coordinates of the blue pixels as a list like this: [(0, 2), (1, 2), (2, 2), (2, 1), (3, 1), (4, 1)]
How can I achieve this?
I am using Python and numpy, but actually a solution in any language including pseudo code would be helpful. I can then try to convert it into a numpy solution.
