Why “cout” works weird for “unsigned char”?
I have the following code: cvtColor (image, image, CV_BGRA2RGB); Vec3b bottomRGB; bottomRGB=image.at<Vec3b>(821,1232); When I display bottomRGB[0] , it displays a value greater than 255. What is the reason for this? As you have commented, the reason is that you use cout to print its content directly. Here I will try to explain to you why this will not work. cout << bottomRGB[0] << endl; Why "cout" works weird for "unsigned char" ? It will not work because here bottomRGB[0] is a unsigned char (with value 218 ), cout actually will print some garbage value (or nothing) as it is just a non