# 11: Additional Topics: Homography, Template Matching, Texture, Image Differencing

In this post, we will look at an overview of the 3 topics.

A **Homography Matrix** is defined as the mapping between two planar projections of an image. It is represented by a 3x3 transformation matrix in a homogenous coordinates space. These transformations can be a combination of rotation, translation, scaling, or skew operations.

There are different homography matrices to choose from, each giving a different form of transformation. The Euclidean method rotates the image while maintaining the original size. The Similarity method maintains the aspect ratio. The Affine method keeps parallel lines parallel. To demonstrate the Projective method, we can look at the 2 examples below:

These work by choosing the points of interest on the original image and specifying the destination for these points. Estimating the transform and warping the image does the trick.

This method of setting explicit source and destination points before estimating the transform and warping the image is not very efficient for quick or real-time applications. The solution therefore is to automate this. Furthermore, this solution builds on template matching, by removing rotational, scale, and intensity invariant limitations.

To demonstrate how **Template Matching** works, we will have a look at this airplane carrier. We need to slice one airplane to set as the template. To locate multiple matches of the template, we look for peaks that have at least a certain value for correlation. This method does not work well when the planes are of different sizes and at different angles.

This template matching can be significantly improved by using SIFT which consider scale and orientation when identifying key points and uses their descriptors to finally match points.

The RANSAC is an iterative method to find the best homography matrix. It randomly selects points and counts the number of inliers. The line of transformation that gives the most number of inliers is chosen.

The spatial arrangement of the intensity values is called **Texture**. There are various type of texture metrics that can be used for segmentation and other purposes. The texture of an image is computed by:

- Define a moving window across our image.
- Compute for the occurrence histogram of the grey levels in the window
- Compute for the Probability array given the window.
- Compute for the corresponding Texture Metric given the Probability array.

This method assigns a specific texture metric at the centre of our moving window. We can then iterate our moving window across the entirety of our image to compute for the texture metric.

Looking at the object above and adding noise to it, we can solve for the local entropy of this window as given. When this window is moved along the entirety of an image and a similar (given some probability threshold) entropy is found, the texture is matched.

**Image Differencing**

If we want to find the difference between 2 pictures, similar to the puzzles we had as kids, we can do a simple difference of 2 gray-scaled images to identify these difference.