I want to convert a numpy.ndarray:
out = [[12 12 12 ..., 12 12 12]
[12 12 12 ..., 12 12 12]
[12 12 12 ..., 12 12 12]
...,
[11 11 11 ..., 10 10 10]
[11 11 11 ..., 10 10 10]
[11 11 11 ..., 10 10 10]]
to RGB img.
The colors are taken from an array:
colors_pal = np.array(
[0,0,128], #ind 0
[0,0,0],
....
[255,255,255]], #ind 12
dtype=np.float32)
So, for example, all the pixels with index 12 will be white (255,255,255).
The way I do it now is very slow (about 1.5 sec/img):
data = np.zeros((out.shape[0],out.shape[1],3), dtype=np.uint8 )
for x in range(0,out.shape[0]):
for y in range(0,out.shape[1]):
data[x,y] = colors_pal[out[x][y]]
img = Image.fromarray(data)
img.save(...)
what is the efficient way to do it faster?