code: function analyzePixels() {
  
      var len = pixels.length;
      var nPix = len / 3;
      indexedPixels = [];
      var nq = new NeuQuant(pixels, len, sample);
  
      // initialize quantizer
      colorTab = nq.process(); // create reduced palette
  
      // map image pixels to new palette
      var k = 0;
      for (var j = 0; j < nPix; j++) {
        var index = nq.map(pixels[k++] & 0xff, pixels[k++] & 0xff, pixels[k++] & 0xff);
        usedEntry[index] = true;
        indexedPixels[j] = index;
      }
  
      pixels = null;
      colorDepth = 8;
      palSize = 7;
  
      // get closest match to transparent color if specified
      if (transparent !== null) {
        transIndex = findClosest(transparent);
      }
    }
docs: Analyzes image colors and creates color map.