I'm loading image into cv::Mat
. For some reason, when I'm printing each pixel data, color doesn't match with actual image pixels. Clearly, there is no (28, 36, 255), (127, 127, 255)
colors on the image. Could someone point to my mistake? Here are code and test image.
cv::Mat img = imread("image.png", CV_LOAD_IMAGE_COLOR);
auto *input = (unsigned char*)(img.data);
int r, g, b;
for (int i = 0; i < img.rows; i++) {
for (int j = 0; j < img.cols; j++) {
b = input[img.step * j + i];
g = input[img.step * j + i + 1];
r = input[img.step * j + i + 2];
std::cout << r << " " << g << " " << b << std::endl;
}
}