How to print out a pixel value in a Mat image

旧时模样 提交于 2019-12-10 19:35:17

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!