本文介绍了如何在opencv中访问Cvmat *的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在opencv中打印存储在CVmat *中的数字?
我在访问cvmat元素时遇到问题.请提出解决方案!

How can I print the numbers stored in CVmat* in opencv?
I am facing a problem in accessing elements of cvmat. Please suggest a solution!

推荐答案

在回答您对aranga的评论时,

In answer to your comment to aranga,

这取决于您的图像,或更确切地说,取决于它具有多少个通道.普通图像将具有3个通道(RGB,尽管实际上是反向的,所以是BGR),您的图像似乎是灰度的,或者无论如何在第一个通道中只有值.

this depends on your image, or more precisely on how many channels it has. A normal image will have 3 channels (RGB, though it is actually in reverse, so BGR), yours seems to be grayscale, or in anycase have only values in the first channel.

我刚刚检查了一下,的确可以,

And I've just checked, indeed if you perform

    cvtColor(src,dst,CV_RGB2GRAY);

要将三通道RGB图像转换为灰度图像,灰度图像只有1个通道.但是也许您会知道为什么您的图像仅使用1个通道...

to convert a three-channel RGB image into grayscale, the grayscale image has only 1 channel. But perhaps you would know why your image is only using 1 channel...

这篇关于如何在opencv中访问Cvmat *的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 11:20