 <p>You have a 2D chroma value in the range 0..1, 0..1</p> <pre><code>r = R/(R+G+B); g = G/(R+G+B); </code></pre> <p>That means for each pixel you have a 2d value you could place somewhere in this continous space</p> <pre><code>^ R |(1,0) | |(0,0) (0,1) G |-----------&gt; </code></pre> <p>If you bin that in a 2x2 way you'll assign each to a bin like</p> <pre><code>R ^ |-------|------| | bin | bin | | | | |-------|------| | bin | bin | | | | |-------|------|&gt;G </code></pre> <p>E.g. a value of [0.3, 0.2] goes into the bottom left. [0.9, 0.9] into the top right. You can make that into a finer 7x7 grid as well.</p> <p>Now you iterate over all the [r,g] values and count how many values go into which bin. Result is maybe something like</p> <pre><code> 30 | 12 ------------ 4 | 12 </code></pre> <p>This is histogram H.</p> <p>Now you can normalize it by converting values to percentage. That's done by dividing by the total. E.g. <code>30 / (30+12+4+12)</code> for the first. And the final result is an array of floats.</p> <pre><code> 0.5 | 0.2 ------------ 0.0 | 0.2 </code></pre>