Ask Your Question

Revision history [back]

warpAffine issues

Hi,

I want to calculate manually the new coordinates of points using a transformation matrix, and then copy some values of the original image to their new coordinates in another one. But i don't have the same result by using warpAffine, mine is obvsiously wrong but i don't know why. I used the formula given in the documentation http://opencv.willowgarage.com/documentation/cpp/imgproc_geometric_image_transformations.html#warpAffine

Here is my code:

for (int i = 0; i < depthMap->height;i++)
{
         for (int j = 0; j < depthMap->width;j++)
         {

         int newJ = (int)(m11*j + m12*i + m13);
         int newI = (int)(m21*j + m22*i + m23);



         if (newI >= 0 && newI < depth->height && newJ >= 0 && newJ < depth->width) 
          setDepth(depth, newI, newJ, getDepth(depthMap, i ,j));  



         else
            setDepth(depth, newI, newJ, 0);
         }
}

m_xx are the components of my matrix (floats). The two images obtained with warpAffine and this method are similar but no pixels fits where it should be.