Quantize an image
<p>My instructor wrote "Write a function that quantizes the image to q grayscale shades. For example, if q=8, replace each pixel between 0-31 by  0, 32-63 by 32, ..., and 224-255 by 224." This is my code so far.</p>

<pre><code>void quantize (int image[][MAXHEIGHT], int width, int height, int q)
{
    const int temp = 256 / q;

    int startPixel, endPixel;
    int indicator = temp; // where the pixels are divided, 0-31, 32-63, etc if q = 8

    while (indicator &lt;= 256)
    {
        startPixel = indicator - temp;
        endPixel = indicator - 1;
        cout &lt;&lt; "start value is " &lt;&lt; startPixel &lt;&lt; " and end value is " &lt;&lt; endPixel &lt;&lt; endl;

        for (int row = 0; row &lt; height; row++)
        {
            for (int col = 0; col &lt; width; col++)
            {
                if ((image[col][row] &gt; startPixel) &amp;&amp; (image[col][row] &lt;= endPixel));
                {
                    image[col][row] = startPixel;
                }
            }
        }

        indicator += temp;
    }
}
</code></pre>

<p>When I try to quantize an image it either turns completely white or completely black. I think I'm looping this function wrong but not sure what to do to fix it.</p>