Search code examples
opencvmappingpixelpanoramashomography

How do I use a Homography Matrix properly?


So I have an image, and a panoramic image. Pixels from image1 are mapped to the panorama using a Homography matrix (is that correct?). I have the Homography Matrix H.

So, for each pixel in panorama, how do I know where the pixel is in image1?

I have the (u,v) coordinates of the pixel in the panorama, an the Homography H that maps image1 to panorama.

What is the formula?


Solution

  • The reverse formula would be: p'=[wx,wy,w] = [u,v,1]*H^-1;
    where H^-1 is the inverse of H; (it exists by definition)
    dividing by the homogeneous coordinate w:
    p = p'/w = [x,y,1], where the coordinates [x,y] map to [u,v] in the panorama.

    The intermediate result p' is a 3-dimensional vector, where the two first elements have to divided by the last one. This applies to both forward and reverse operations.

    http://en.wikipedia.org/wiki/Homography