Buffer.unmap();
}

function drawHistogram(histogram, channels, height = 100) {
  // find the highest value for each channel
  const max = [0, 0, 0, 0];
  const total = [0, 0, 0, 0];
  histogram.forEach((v, i) => {
    const ch = i % 4;
    max[ch] = Math.max(max[ch], v);
    total[ch] += v;
  });
  console.log('total:', total);

  const numBins = histogram.length / 4;
  const canvas = document.createElement('canvas');
  canvas.width = numBins;
  canvas.height = height;
  document.body.appendChild(canvas);
 