I have converted an image into a 2-dim Array to make some analysis:
im=imageio.imread(file)
im2D=im[:,:,0]
Now I need an efficient way to turn over this step. For the moment I'm doing this with 2 for-loops but I think this is really inefficient:
NewImage=np.zeros((len(im2D),len(im2D[0]),3,dtype=int)
for x in range(len(im2D)):
for y in range(len(im2D[0])):
NewImage[x][y]=[im2D[x][y],im2D[y][y],im2D[x][y]]
NewImage=NewImage.astype(np.uint8)
Example: imageio gives me something like this:
im=Array([[[255,255,255,255],
...
[255,255,255,255]],
[ 0, 0, 0, 0],
...
[255,255,255,255]]],dtype=uint8)
and im[:,:,0]
gives me something like this:
im2D=Array([[255,...,255],
...
[ 0,...,255]],dtype=uint8)