问题描述
我试图采取的imageData形象在这其中w =宽度形象和H =图像高度
的for(int i = X; I< X + H,我++)//帧的像素高度
{
对于(诠释J = Y; J< Y + W; J ++)//帧像素的宽度
{
INT POS = I * W *通道+ J; //渠道为3。RGB
如果不存在任何数据//
如果(数据并行>的imageData [POS] 0)//获取数据(这里是怎么走的问题)
{
XPOS + = j的;
yPos + =我;
nPix ++;
}
}
}
jeff7给你一个链接到一个很老的版本的OpenCV。 OpenCV的2.0有一个新的C ++包装比在链接中提到的C ++封装好得多。我建议你阅读的关于如何访问各个参考像素。
另一个要注意的是:如果在外部循环为在y方向(垂直)的环和内环是在x方向上的循环。 OpenCV的是C / C ++,它排在各大门店的值。
I am trying to take the imageData of image in this where w= width of image and h = height of image
for (int i = x; i < x+h; i++) //height of frame pixels
{
for (int j = y; j < y+w; j++)//width of frame pixels
{
int pos = i * w * Channels + j; //channels is 3 as rgb
// if any data exists
if (data->imageData[pos]>0) //Taking data (here is the problem how to take)
{
xPos += j;
yPos += i;
nPix++;
}
}
}
jeff7 gives you a link to a very old version of OpenCV. OpenCV 2.0 has a new C++ wrapper that is much better than the C++ wrapper mentioned in the link. I recommend that you read the C++ reference of OpenCV for information on how to access individual pixels.
Another thing to note is: you should have the outer loop being the loop in y-direction (vertical) and the inner loop be the loop in x-direction. OpenCV is in C/C++ and it stores the values in row major.
这篇关于如何从一个OpenCV的RGB图像(图像3channel)访问图像数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!