如何在Mat图像中打印出像素值 [英] How to print out a pixel value in a Mat image

查看:278
本文介绍了如何在Mat图像中打印出像素值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,如何确定图像中的像素值.

I have a question about how to cout a pixel value in an image.

例如:我有图像,尺寸为10 * 10,我想在图像的第5行和第5列中找出像素值,这就是我编写的代码.

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;

但是结果在下图中

我想知道为什么它会打印出如此奇怪的符号?

I'm wondering why it prints such strange symbol?

有人可以帮助我吗?非常感谢!!!

Can anyone help me? Thanks a lot!!!!

推荐答案

您正在打印char值.因此,该值将转换为该值的ANSI表示形式.如果要查看数字,请强制转换结果:

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))

这篇关于如何在Mat图像中打印出像素值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆