Fill in numpy array using fancy indexing

Viewed 17

Suppose I have an say NxM called Image, and I have 3 1xK arrays, x_array, y_array, z_array where x_array and y_array represent index values and z_array represents value to insert, ex:

Image[y_array[0], x_array[0]] = z_array[0]

What is the best way to do this?

1 Answers

You can directly index using the arrays:

Image[x_array, y_array] = z_array
Related