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
  • 20,813
  • 6
  • 58
  • 82
Alvar
  • 489
  • 5
  • 17

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
  • 51,549
  • 10
  • 60
  • 87