i am trying to change certain matrix values of a 2D numpy array. I need this to classify areas of an image in pixel level.
Imagine having a matrix like:
a = [ [1, 2, 3, 4 ]
[5, 6, 7, 8 ]
[9, 10, 11, 12]
[13, 14, 15, 16] ].
I want to change values by "drawing" a line. Like i put a line through the values 5, 11 and 16. I'd wish to change the values below this line to 0. So having:
a = [ [1, 2, 3, 4 ]
[5, 6, 7, 8 ]
[0, 0, 11, 12]
[0, 0, 0, 16] ].
Regularly with banded matrices and diagonal functions it is easy to change matrix values. But how to do with irregular geometric wishes? Another use case is to have a geometric figure, or in detail the corner points of a geometric figure. Is there a way to give four corner points to create a box?
E.g. corner_points = [ [1,1], [3,1], [1,2], [4,3] ]
Which would lead to:
a = [ [0, 0, 3, 4 ]
[0, 0, 0, 8 ]
[0, 0, 0, 12]
[13, 14, 0, 16] ]
I don't need it to be perfectly accurate, a rough approximation is really helpful!
Thanks in advance and if i failed to explain it right, please ask questions so i can do this challenge.