Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between phase correlation and template matching in OpenCV?

I recently discovered phase correlation in OpenCV, which with the Log Polar Transform (LPT) can perform rotation and scale invariant template matching. I'm wondering what the difference is between this method and all the template matching methods described here http://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/template_matching/template_matching.html which seem far less robust to any rotation or scaling.

I guess my question is what are the advantages and disadvantages of:

  1. Phase correlation + Log polar transform.
  2. Template matching .
  3. Full flown features matching with something like SIFT.
like image 570
nickponline Avatar asked May 10 '16 16:05

nickponline


People also ask

What is OpenCV template matching?

Template Matching is a method for searching and finding the location of a template image in a larger image. OpenCV comes with a function cv. matchTemplate() for this purpose.

What is template matching in image processing?

Template matching is a technique in digital image processing for finding small parts of an image which match a template image. It can be used in manufacturing as a part of quality control, a way to navigate a mobile robot, or as a way to detect edges in images.

What is phase correlation in image processing?

Phase correlation is an approach to estimate the relative translative offset between two similar images (digital image correlation) or other data sets. It is commonly used in image registration and relies on a frequency-domain representation of the data, usually calculated by fast Fourier transforms.

How template matching works?

Template matching works by "sliding" the template across the original image. As it slides, it compares or matches the template to the portion of the image directly under it. It does this matching by calculating a number. This number denotes the extent to which the template and the portion of the original are equal.


1 Answers

Phase correlation and log-polar transform are implemented in the frequency domain, both these algorithms are derived from the Fourier shift theorem that two translated images will show similar phase differences in the frequency domain. Phase correlation is able to register only translation motion whereas the log-polar transform works in the log-polar domain which essentially converts rotation and scale changes into linear translation. So using log-polar matching you can register two images that are scaled rotated and translated copies of each other. Both of these algorithms cannot register deformable transformation. For detailed analysis regarding ambiguity and range of rotation and scale variation these algorithms can determine, you can refer to this paper "http://ieeexplore.ieee.org/document/901003/".

Template matching is essentially finding a known template's presence in a base image using varied similarity metrics(Sum of squared differences, normalized cross-correlation, Hausdorff distance, etc). So the match can be applied on either spatial attribute( intensity image, edge map, HOG) or frequency attribute(phase). Phase correlation and log-polar matching can be implemented on same size images so phase-based template matching will essentially correspond to finding the same patch in the search space with the highest value of correlation.

SIFT, SURF, etc generate a large feature vector set dependent on various parameters such that it is unaffected by scale variation, noise, and illumination changes. This is a very wide topic and many papers are available online comparing their functioning.

According to my experience SIFT, SURF is a much more robust classifier in localizing the object in a single frame but if you are planning to locate an object in a video where computational time is a limiting factor then template matching serves better.

like image 121
Nikita Chopra Avatar answered Sep 24 '22 19:09

Nikita Chopra