如何打印R G和B矩阵

How to print R, G and B matrices

本文关键字:矩阵 何打印 打印      更新时间:2023-10-16

我有以下代码,我的频道数是3

IplImage* img_crop_mat = cvLoadImage("....", 1);
...
int b = 0;
uchar* rgb = (uchar*) img_crop_mat->imageData;

我想有R, GB矩阵在一个循环中,浏览整个图像:

for (int y = b; y < height - b; y++)
{    
    ???
    for (int x = b; x < width - b; x++)
    {
        ????
    }
}

以前的论坛关于我的问题处理CvMat,但不与指针作为我的代码。

我必须考虑哪些指标?

您可以使用以下宏访问3通道8u图像的任意像素:

CV_IMAGE_ELEM(myImage, unsigned char, y, x*3 + ChannelOfInterest)

这是一个左值,所以你可以使用它的值,或者你可以改变像素的值。

默认情况下

,

ChannelOfInterest = 0, blue
ChannelOfInterest = 1, green
ChannelOfInterest = 2, red

实际的数据结构非常简单,查找CV_IMAGE_ELEM的定义