I can only find results that use tuples of coordinates to assign certain values, like this one.
I want to assign values to a 2-dimensional array as a function of their coordinates. The simplest case would be to set the value of each element to their second index (e.g. x-coordinate). Such that,
x[0][0] = 0
x[1][0] = 0
...
x[2][0] = 0
x[0][1] = 1
x[0][2] = 2
...
More complex case would be to set these values to the Euclidean distance to a certain point (x, y).
My current solution is to use a for-loop, which is definitely not efficient. A vectorized implementation would be nice.
My current implementation:
x_mask = np.zeros((256, 256))
for i in range(256):
for j in range(256):
x_mask[i][j] = j