## Introduction

Homography is a projective transformation in which projections are used to connect two images. Homographies were initially introduced to study shifts in perspective, and they have enabled people to understand better how images change when we look at them from a different perspective.

Homography describes the projective geometry of two cameras and a world plane. Homography is a technique for mapping images of locations on a world plane from one camera view to another. Because it is based solely on the intersection of planes and lines, it is a projective connection. As depicted in the diagram below:

There are two only cases for which Homography applies (both cases assume that the world view can be modelled by plane):

- Images are captured by the same camera but at a different angle (the world is now essentially a plane)
- Two cameras are viewing the same plane from a different location.

## Understanding Homography Theoretically

Homography (also known as planar Homography) is a change that takes place between two planes. In other terms, it is a transformation of a picture between two planar projections. In a homogeneous coordinates space, it is represented by a 3x3 transformation matrix. The homography matrix is expressed mathematically as:

So Homography is nothing but a function that converts one planar projection of an image to some other plane.

Let's suppose we want to paste some logo to some video or another image; there, we will need this Homography as we are going to map the image points to a new image.

So let's see more details about how we calculate the homography matrix.

**Calculating Homography using point correspondences**

Let's go over some of the attributes of a homography matrix before we get into how to calculate Homography using point correspondences. Homography connects points in the first perspective to points in the second view, and because neither view has any constraints, it is a full rank (=3) matrix. Homography is also defined up to a scale (c in the preceding equation), which means it can be altered by a non-zero constant without affecting projective transformation. Homography has 8 degrees of freedom despite the fact that it comprises nine elements (3x3 matrix), i.e. there are eight unknowns to solve. We only need 4 points in the football goal post example because each point includes x and y coordinates, and there are a total of 8 unknowns to solve H for a unique solution. These four points could be the goalpost's four corners.

To make the solution to equation Ah=0 more stable in the presence of noise and to prevent divergence from the right answer, Hartley and Zisserman recommended a normalisation step before calculating h. The goal is to find a transformation matrix T and T' that transforms x and x' so that the centroid of these points is the coordinate origin and the average distance from it is fixed. Using the given equation, we can recover the original homography matrix after calculating H' from the altered points.