Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm using OpenCV's findHomography function (with RANSAC) in Python to find the transformation between two sets of points.

Looking at the documentation , the output is a mask and a transformation matrix.

The documentation is not clear about what the mask represents, and how the matrix is structured.

Is a 1 in the output mask a point that fits the found transformation or a point that was ignored? And could you explain the makeup of the 3x3 output transformation matrix?

Thanks in advance and sorry if I missed some documentation which explains this.

Don't forget to click the empty check mark next to the post. If you liked the answer that is. Jay Sep 5, 2014 at 20:52

Based on my limited search, mask returned by findHomography() has status of inliers and outliers, i.e. it's a matrix representing matches after finding the homography of an object.

This answer addresses your first question.

This answer addresses what a mask is and what are its dimensions.

This answer actually answers the OP's question regarding the mask, which is what I was actually looking for. The highest upvoted answer mentions to simply ignore the mask which is not right. rayryeng Dec 7, 2020 at 17:33 @AlexanderSoare :D. I'm surprised to see the influx of downvotes. It was only a couple of months ago when I made the comment about the answer having the highest votes. rayryeng Mar 31, 2021 at 17:53

Well what do you need to do with the mask? Because that field is not needed so you don't have to put any mask.

As for the resulting matrix. It is called a homography matrix, or H matrix and it represents the transformation of one point in an image plane to the same point in another image plane.

 X1 = H * X2

The point X1 is the same point (X2) in a different plane.

So the H matrix is basically the description of how one point in, lets say, image 1 matches 1 point in image2.

Thanks Jay - The reason I want to see the output to the Mask and matrix, is that I have multiple images I compare my query image with and I want to see which provided the best match. And for the H matrix, which are the scale, rotation, etc. values? – Akanes Sep 5, 2014 at 21:10 The H matrix is the rotation. If you are inputting matched points manually then the scaling is done for you. No need to do anything else. Just plug that H matrix into cv::warpedPerspective and you shall have a warped image1 into image2 frame – Jay Sep 5, 2014 at 21:23 The mask is important to know which inliers contributed to the homography. It is extremely important for image stitching when deciding which images overlap. This answer would be better if it mentioned the purpose of the mask rather than dismissing it completely. Though it may not be needed for warping an image, the original question asks what the mask is for which this answer doesn't address. FYI, H is not simply a "rotation". It is a plane to plane mapping. In special circumstances, the homography does simplify to a rotation matrix but in general this is not true. – rayryeng Dec 9, 2020 at 3:29

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.