19

Hi i am a beginner in computer vision and i wish to know what exactly is the difference between a homography and affine tranformation, if you want to find the translation between two images which one would you use and why?. From papers and definitions I found online, I am yet to find the difference between them and where one is used instead of the other.

Thanks for your help.

hippietrail
  • 13,703
  • 15
  • 87
  • 133
Matt Brown
  • 259
  • 1
  • 2
  • 11
  • I'm assuming you're referring to what the individual components of a 3x3 homography matrix are: http://stackoverflow.com/questions/12070411/what-do-the-elements-in-a-homography-matrix-mean, but if you're just after translation then this is just the first two row values in the last column which represent x and y translation respectively, an affine transformation keeps straight lines parallel, see http://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.html – EdChum Mar 03 '17 at 14:27
  • no i understand that but why would you use findhomography instead of let's say getAffineTransform to find the x and y translation? – Matt Brown Mar 03 '17 at 14:31
  • so you don't get a perspective transformation with affine transformation but you do with full homography: https://en.wikipedia.org/wiki/Transformation_matrix#Perspective_projection. You don't need a full homography or even affine to find translation, you can use camshift if you want translation and scale. You want a full homography for perspective warping calculation or camera calibration perhaps. You've not explained what your actual aim is – EdChum Mar 03 '17 at 14:32
  • i am getting the initial frame where x and y 0,0 then any offset i calculate it using findHomography so x will be 5 and y 2 for example...I think perspective will change in this situation as the camera will be attached to a drone which will try to correct itself into initial positon based on those inputs but im still not sure if i should use findhomography i am also using findhomography to perform ransac for better accuracy. – Matt Brown Mar 03 '17 at 14:39
  • I'm not sure this is a programming question now, you may wish to post on opencv forum or on a different SO site as what you're talking about is too complex to answer in a simple Q+A site here – EdChum Mar 03 '17 at 14:42
  • not really i have done the programming but would like to know what is the difference between affine and homography transformation also would like to know if by homography you get perspective of x and y – Matt Brown Mar 03 '17 at 14:46

2 Answers2

24

A picture is worth a thousand words: enter image description here

john ktejik
  • 4,724
  • 3
  • 38
  • 48
18

I have set it down in the terms of a layman.

Homography

A homography, is a matrix that maps a given set of points in one image to the corresponding set of points in another image.

The homography is a 3x3 matrix that maps each point of the first image to the corresponding point of the second image. See below where H is the homography matrix being computed for point x1, y1 and x2, y2

enter image description here

Consider the points of the images present below:

enter image description here

enter image description here

In the case above, there are 4 homography matrices generated.

Where is it used?

  1. You may want to align the above depicted images. You can do so by using the homography.

enter image description here

Here the second image is mapped with respect to the first

  1. Another application is Panoramic Stitching

Visit THIS BLOG for more

Affine transformation

An affine transform generates a matrix to transform the image with respect to the entire image. It does not consider certain points as in the case of homography.

Hence in affine transformation the parallelism of lines is always preserved (as mentioned by EdChum ).

Where is it used?

It is used in areas where you want to alter the entire image:

  • Rotation (self understood)
  • Translation (shifting the entire image by a certain length either to top/bottom or left/right)
  • Scaling (it is basically shrinking or blowing up an image)

See THIS PAGE for more

Community
  • 1
  • 1
Jeru Luke
  • 13,413
  • 9
  • 57
  • 71
  • So just to be clear, you need a unique homography for each point? I don't know the theory behind it, but for datasets I've seen, there is only one homography per transformed image. Not a separate homography for each pixel. – Jonathan Aug 06 '19 at 19:04
  • To further clarify, is it that homography is a technique to relate pixel locations between two images, and if the transformations are affine transformations, that is, they are planar transformations, then a single homography can be used. If the scenes are not planar, then homographies for sure cannot be used. That is my understanding. Can you please confirm this? In what type of situations do you need more than one homography? – Jonathan Aug 06 '19 at 19:07