问题
I have a question about how to cout a pixel value in an image.
For example: I have image and size is 10*10, I want to cout the pixel value at row 5 and column 5 in the image, here is what I code.
Mat img;
cout << img.at<uchar>(5,5) << endl;
But the result is in the following image
I'm wondering why it prints such strange symbol?
Can anyone help me? Thanks a lot!!!!
回答1:
You are printing char value. So the value will translate into ANSI representation of that value. If you want to see a number, cast the result:
static_cast<int>(img.at<uchar>(5,5))
来源:https://stackoverflow.com/questions/36281362/how-to-print-out-a-pixel-value-in-a-mat-image