function distribution = distributionFromImage(image, powerOfTwo)
  bins = 2 ^ powerOfTwo;
  valuesPerBin = 256 / bins;

  rows = size(image, 1);
  cols = size(image, 2);

  distribution = zeros(1, bins);
  for row = 1 : rows
    for col = 1 : cols
      bin = ceil(double(image(row, col) + 1) / double(valuesPerBin));
      distribution(bin) = distribution(bin) + 1;
    end
  end

  distribution = distribution * (1.0 / double(rows * cols));  
end
