Checking Image Overlap with Mathematica

Written by on December 5, 2016 in Image Processing, Mathematica with 0 Comments

Recently I had to solve a seemingly simple problem: Given two images, can we find out if there is any overlap between the two?

Where does such a requirement arise? One use case is in photogrammetry, where in order to build an orthomosaic from multiple images, there must be at least 70% overlap between consecutive images.

We will make the following assumptions:

  • All images are of the same dimension
  • All images are of good quality

Clearly, we do not want brute-force comparison, which might take considerable time. The idea is to get a fairly quick estimate.

I did a google search and got some useful links that talk about this aspect. In this blog and the next one, I am going to discuss a few of the techniques I found interesting.

As usual, Mathematica is the first choice from my toolkit.

First I import 4 sample images, and then display them in a table form for convenience.

Sample Images

Sample Images

Visual inspection tells us that images 1, 2 and 3 have substantial overlap, but image 4 is very different, having no overlap with the other three.

Technique-1:

OK, let us look at the first technique. This uses Mathematica function ImageFeatureTrack to track features from one image to the other.

Here is a simple function definition that highlights tracked features on two given images.

Highlight Tracked Features

Highlight Tracked Features

Next, we call this function on the pairs (Image1, Image2) , (image2, Image3), and (Image1, Image4):

Highlighting Features in Image Pairs

Highlighting Features in Image Pairs

We see two interesting things here:

  • Images 1 and 2 have significant overlap, but some points appear to be missing in the tracking
  • Images 1 and 4 have very little overlap, but the tracking shows some amount of commonality

Relatively speaking, we can probably agree that the overlaps can be ranked in descending order as follows:

  • Image2, Image3
  • Image1, Image2
  • Image1, Image4

Here is a function definition for computing the percentage of overlap between two given images, using the ImageFeatureTrack function:

Function to Calculate Overlap

Function to Calculate Overlap

Let us use this function to calculate the overlap across our sample images:

Percentage Overlap

Percentage Overlap

Broadly and intuitively, the values seem to agree with our expected relative ordering. However, the absolute percentage value is questionable. For example, it is difficult to believe that Images 1 and 4 have 50% overlap. This could introduce false positives if we are trying to filter several images based on the overlap. Looks like our approach requires improvement.

We shall discuss another technique in the next post.

Bye, till then!

Subscribe

If you enjoyed this article, subscribe now to receive more just like it.

Subscribe via RSS Feed

Leave a Reply

Your email address will not be published. Required fields are marked *

Top