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
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
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)