【发布时间】:2012-02-15 10:51:32
【问题描述】:
我正在将一块像素从一个图像复制到另一个图像,因此我没有得到 1:1 的映射,但新图像的强度与源图像相差 1 或 2 个强度级别。
你知道是什么原因造成的吗?
这是代码:
void templateCut ( IplImage* ptr2Img, IplImage* tempCut, CvBox2D* boundingBox )
{
/* Upper left corner of target's BB */
int col1 = (int)boundingBox->center.x;
int row1 = (int)boundingBox->center.y;
for(int i=0; i<tempCut->height; i++)
{
/* Pointer to a row */
uchar * ptrImgBB = (uchar*)( ptr2Img->imageData + (row1+i)*ptr2Img->widthStep + col1 );
uchar * ptrTemp = (uchar*)( tempCut->imageData + i*tempCut->widthStep );
for(int i2=0; i2<tempCut->width; i2++)
{
*ptrTemp++ = (*ptrImgBB++);
}
}
}
【问题讨论】:
-
您应该为您感兴趣的编程语言添加一个标签。我认为这是 C 代码,对吧?
-
它的 c++。谢谢你的评论。
-
我觉得opencv就够了。
-
看起来您使用的是较旧的 C 接口。如果你安装了 OpenCV 2,你应该使用 Mat,而不是 IplImage。
标签: c++ opencv mapping pixel copying