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.
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.
Next, we call this function on the pairs (Image1, Image2) , (image2, Image3), and (Image1, Image4):
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:
Let us use this function to calculate the overlap across our sample images:
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!
Recent Comments