I want to convert an image to 2D array with 5 columns where each row is of the form [r, g, b, x, y]. x, y is the position of the pixel and r,g,b are the pixel value
[r, g, b, x, y]
I used "+" to combine two tuple, and use .append() to make "data" list.No need to use Numpy here.
.append()
row,col = im.size data=[] #r,g,b,i,j pixels=im.load() for i in range(row): for j in range(col): data.append(pixels[i,j]+(i,j))