C++, Negative RGB values of pixels using OpenCV
I'm using OpenCV to iterate through an image and find the colour of each pixel, here's some of the code I'm using: IplImage* img = cvLoadImage("c:\\test.png"); int pixels = img->height * img->width; int channels = img->nChannels; for (int i = 0; i < pixels*channels; i+= channels) { unsigned char red = img->imageData[i + 2]; unsigned char green = img->imageData[i + 1]; unsigned char blue = img->imageData[i]; outputRGBValues(red, green, blue); if (red == REDCOLOUR && green == GREENCOLOUR && blue == BLUECOLOUR) { count++; } } cvReleaseImage(&img); When I run it, it outputRGBValues outputs