Easy 10x speedup in mapping to a 256-colour palette

If you’ve optimised your palette generation code, you may find that the much simpler map-to-palette operation is now starting to take a significant part of the execution time. Assuming you want to map each pixel to its closest palette colour as measured by Euclidean distance in some colour space, then the brute-force approach looks like… More Easy 10x speedup in mapping to a 256-colour palette