0

Without using for loop.

How can I attach the x,y coordinate on to each pixel of a rgb image in numpy?

such that

image[0,0,:] = (r,g,b,x,y) where x,y is the coordinate of the pixel

ZdaR
  • 22,343
  • 7
  • 66
  • 87
Alvar
  • 529
  • 5
  • 18

1 Answers1

2

Suppose rgb and xy are your (w,h,3) and (w,h,2) arrays, respectively. Then you can concatenate them along the third axis:

image = np.concatenate((rgb, xy), axis=2)
DYZ
  • 55,249
  • 10
  • 64
  • 93