redbook Histogram example Problem

http://www.java-tips.org/other-api-tips/jogl/how-to-compute-the-histogram-of-an-image-using-glhistogram-fun.html

This is an incorrect accessing of color channels. Since, there are three channels the loops should access every third value not 0,1,2,2,3,4

[quote] /* Plot histogram */
gl.glBegin(GL.GL_LINE_STRIP);
gl.glColor3f(1.0f, 0.0f, 0.0f);
for (int i = 0; i < HISTOGRAM_SIZE; i++)
gl.glVertex2s((short) i, values.get(i * 2));
gl.glEnd();

gl.glBegin(GL.GL_LINE_STRIP);
gl.glColor3f(0.0f, 1.0f, 0.0f);
for (int i = 0; i < HISTOGRAM_SIZE; i++)
  gl.glVertex2s((short) i, values.get(i * 2 + 1));// [i][1]);
gl.glEnd();

gl.glBegin(GL.GL_LINE_STRIP);
gl.glColor3f(0.0f, 0.0f, 1.0f);
for (int i = 0; i < HISTOGRAM_SIZE; i++)
  gl.glVertex2s((short) i, values.get(i * 2 + 2));// [i][2]);
gl.glEnd();

[/quote]
Should access every third value 0,1,2,3,4,5

 /* Plot Histogram */
        gl.glBegin(GL.GL_LINE_STRIP);
        gl.glColor3f(1.0f, 0.0f, 0.0f);
        for (int i = 0; i < HISTOGRAM_SIZE; i++)
            gl.glVertex2s((short) i, values.get(i * 3));
        gl.glEnd();

        gl.glBegin(GL.GL_LINE_STRIP);
        gl.glColor3f(0.0f, 1.0f, 0.0f);
        for (int i = 0; i < HISTOGRAM_SIZE; i++)
            gl.glVertex2s((short) i, values.get(i * 3 + 1));// [i][1]);
        gl.glEnd();

        gl.glBegin(GL.GL_LINE_STRIP);
        gl.glColor3f(0.0f, 0.0f, 1.0f);
        for (int i = 0; i < HISTOGRAM_SIZE; i++)
            gl.glVertex2s((short) i, values.get(i * 3 + 2));// [i][2]);
        gl.glEnd();

        gl.glFlush();

Attached is a corrected image result.