Color quantization diluting pure whites
<p>I have a simple quantization function</p>

<pre><code>public static int quantize(int oldpixel) {

    int r = (oldpixel &gt;&gt; 16) &amp; 0xff;
    int g = (oldpixel &gt;&gt; 8) &amp; 0xff;
    int b = (oldpixel &gt;&gt; 0) &amp; 0xff;

    int color = 0xff &lt;&lt; 24 | (((int) ((r) / 32) * 32) &amp; 0xff) &lt;&lt; 16 | 
            (((int) ((g) / 32) * 32) &amp; 0xff) &lt;&lt; 8 | 
            (((int) ((b) / 32) * 32)&amp; 0xff) &lt;&lt; 0;
    return color;
}
</code></pre>

<p>What it does is reduce a color to a lower detail color, then expands it, this artificially limits the pallet and I'll use it for a dither filter, an image through the function produces this</p>

<p>In:
<a href="https://i.stack.imgur.com/9yKK3.png" rel="nofollow noreferrer">Unquantized hue wheel</a>
Out:
<a href="https://i.stack.imgur.com/9yKK3.png" rel="nofollow noreferrer">Quantized hue wheel</a></p>

<p>This is almost perfect as the result, except the whites are reduced to a gray, I understand the cause is my flooring of divided colors in the algorithm, but I do not know how to fix this, any suggestions would be appreciated</p>

<p><a href="https://i.stack.imgur.com/9yKK3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9yKK3.png" alt="enter image description here"></a></p>

<p><a href="https://i.stack.imgur.com/7Lu1U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Lu1U.png" alt="enter image description here"></a></p>