       s: zero new Array 101 # [0.0, 1.0] -> [0, 101]
       c: zero new Array 135 # https://github.com/gka/chroma.js/issues/63
       l: zero new Array 101 # [0.0, 1.0] -> [0, 101]
-    computeHistogram imageData.data, result, ->
+    computeHistogram imageData.data, result, c.params.step, ->
       outPorts.histogram.send result
       do callback


  c.inPorts.add 'canvas',
    datatype: 'object'
  c.outPorts.add 'histogram',
    datatype: 'object'
  c.outPorts.add 'error',

  res.c[c] += 1
  do callback

computeHistogram = (data, res, step=defaultStep, callback) ->
  rgba = 4
  coutHistograms = 0
  step = if (data.length < (step * rgba)) or (step < 1) then 1 else step
  pixels = data.length / (rgba * step)
  last = data.length - step * rgba
  for index in [0...data.length] by step * rgba
    addEntryHistogram data, res, index, ->
      if index >= last
        # Normalize such that 1.0 means all pixels have this color
        for histogram of res
          normalize res[histogram], pixels, ->
