如何打印R G和B矩阵
How to print R, G and B matrices
我有以下代码,我的频道数是3
IplImage* img_crop_mat = cvLoadImage("....", 1);
...
int b = 0;
uchar* rgb = (uchar*) img_crop_mat->imageData;
我想有R
, G
和B
矩阵在一个循环中,浏览整个图像:
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的定义
相关文章:
- 以螺旋方式打印矩阵的程序.(工作不好)
- cout (<<) 重载运算符不打印减去的矩阵
- 使用用户输入打印 6X10 矩阵的代码 - C++
- 我编写了以下代码来读取C++矩阵,然后打印其行和列.我收到此错误
- 使用单循环打印矩阵的L部分
- 打印矩阵后分割错误,但在打印额外行后修复(ostream <<操作器)
- 打印出矩阵中最长的增加路径
- 按矩阵打印字母
- 使用动态规划在矩阵中的所有可能路径中具有最小总和的打印路径
- C++中的矩阵(打印中间行、打印中间列等)
- 添加两个矩阵会打印一列垃圾数据 c++
- 在C 中打印矩阵二级对角线,用于循环
- 我的 4 x 4 矩阵没有打印出C++
- 期望:代码打印出x(您键入的)在矩阵中出现的次数.实际:代码打印出值量
- 输出是从您输入的矩阵中打印出矩阵的转置,但我的代码只是打印出您输入的第一个矩阵
- 如何在复杂的CPP项目中在gdb中打印犰狳矩阵
- 打印此矩阵的 if 语句是什么
- 超载Ostream运算符从文件打印矩阵
- 我的c++程序读取一个矩阵并打印出非零的数字,这产生了一个运行时错误
- Armadillo c++矩阵库-打印一个矩阵的字符