Saturday, August 13, 2005

copy, map image regions to image

In matlab: newimg2[i,j], im2[m,n], both are 3 channels
copy im2 to newimg2 in opencv

for (int i=rmin1-1, int m=rmin2-1; i rmax1, m rmax2; i++, m++)
{
for (int j=cmin1-1, int n=cmin2-1; j cmax1, n cmax2; j++, n++)
{
(*(newimg2->imageData + i*newimg2->widthStep + j)) =
(*(im2->imageData + m*im2->widthStep + n));
(*(newimg2->imageData + i*newimg2->widthStep + j+1)) =
(*(im2->imageData + m*im2->widthStep + n+1));
(*(newimg2->imageData + i*newimg2->widthStep + j+2)) =
(*(im2->imageData + m*im2->widthStep + n+2));
}
}

No comments:

Post a Comment