going over pixels

in this tutorial:
http://www.openframeworks.cc/tutorials/first%20steps/002-openFrameworks-for-processing-users.html

it says:

  
int colorIndex = y*(myOFImage.width*3)+x*3; // yPos * width * 3 + xPos * 3 = the red channel position  

But isn’t the line above for the blue channel?

Also what is a good way to compare every pixel of a image to see if it mach a certain color?

For now i have something like this:

  
if(imagePixels[pixelIndex] == hitColor.r && imagePixels[pixelIndex+1] == hitColor.g && imagePixels[pixelIndex+2] == hitColor.b) {  
        return false;  
    }  

no that will give you the red channel, this:

  
  
int colorIndex = y*(myOFImage.width*3)+x*3+2;  
  

will give you the blue channel.

also you can use getPixelsRef() in most classes that contain pixels which will return an ofPixels reference which allows to do things like:

  
  
if(img.getPixelsRef().getColor(x,y) == hitColor)  
  

but what you have is ok and should be slightly faster than getColor

thanks man.