Understanding Homography (a.k.a Perspective Transformation)

Looking at things from different perspectives

Socret Lee
Towards Data Science
6 min readJan 31, 2022

Transformation through Homography. Image by Author.

I. Motivation

For those familiar with document scanner apps, you probably notice that the results produced by those apps, no matter how you hold your phone, appear as if you scanned the documents directly from the top (bird’s-eye view). While working on a similar app, I learned to produce the same feature through a computer graphics technique called Homography (a.k.a. Perspective Transformation). Therefore, in this post, I want to explain this concept and share a Python implementation to perform such a technique.

II. Homography (a.k.a Perspective Transformation)

Linear algebra holds many essential roles in computer graphics and computer vision. One of which is the transformation of 2D images through matrix multiplications. An example of such a transformation matrix is the Homography. It allows us to shift from one view to another view of the same scene by multiplying the Homography matrix with the points in one view to find their corresponding locations in another view (Equation 1).

Equation 1: Homography Transformation. Image by Author

Our goal is to understand how matrix H came to be and how to estimate the entries of matrix H. To do so, we first need to understand three essential concepts: Homogenous Coordinates, the Projective Space, and the Pin Hole Camera Model.

Homogenous Coordinates and The Projective Space

Figure 1: Visualization of the Projective Space. Image by Author.

Try this interactive website to get a better intuition about how the Homogeneous coordinates and the projective space work

Homogenous Coordinates are a system of coordinates used in the projective space. You can think of the projective space as a plane located at Z=1 in the 3D space. Lines that cut through the origin of the 3D space and intersect the Z=1 plane form points in the projective space. Furthermore…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Just a guy learning and writing about what he has learnt