Solved by albanD in post #2 
              
              
                Hi, 
Yes I would say that doing this as a single indexing operation would make it much faster. 
Maybe something as simple as colors[x]? Or colors[x.flatten()].reshape(x.shape) ?