I have
- an (height x width x 3) RGB image img
- a (256 x 256 x 256) matrix color_mapping mapping colors
- a (height x width) matrix pixel_result which I want to fill with the elements mapped with color_mapping for each pixel of the image
How can I fill that last matrix efficiently?
So far, I simply run through all the pixels in for loops, but I'm wondering if there is a more efficient way to do it
for i in range(width):
for j in range(height):
pixel_result[j,i] = color_mapping[img[j,i,0],img[j,i,1],img[j,i,2]]