function getColorIndex(r, g, b) {
        return (r << (2 * sigbits)) + (g << sigbits) + b;
    }
Basic Javascript port of the MMCQ (modified median cut quantization)
algorithm from the Leptonica library (http://www.leptonica.com/).
Returns a color map you can use to map original pixels to the reduced
palette. Still a work in progress.

@author Nick Rabinowitz
@example

// array of pixels as [R,G,B] arrays
var myPixels = [[190,197,190], [202,204,200], [207,214,210], [211,214,211], [205,207,207]
                // etc
                ];
var maxColors = 4;

var cmap = MMCQ.quantize(myPixels, maxColors);
var newPalette = cmap.palette();
var newPixels = myPixels.map(function(p) {
    return cmap.map(p);
});