Template Matching

DONGWOOK LEE·2021년 7월 12일
0
post-thumbnail

Template Matching is one of the famous and fundamental Computer Vision technique for Object Detection/Recognition. Via Template Matching, the computer figures out whether the test image contains a given template in it or not. (In the thumbnail image, the pentagon image on the right side is the template image and the polygon set image on the left side is the test image.)

However, as you can implicitly recognize, the template image is just a 'partial patch' of the test image. This means that the computer needs to skim through the whole range of the test image to figure out whether there exists a template image in it or not. We call this method 'Sliding Window'.

As shown above, the computer iteratively compares the template image and the window of test image. We can say that the disadvantage of using Sliding Window method is long computation time, but advantage of using it is that we can exactly locate where the template image (or object) is.

For the comparison, we have 6 well-known equations, by which the computer determines whether the window of the test image is identical to the given template image. Below is the set of equations used for Template Matching.

You can see every equation is based on pixel value difference calculation. It is optional to use one of the equations above for template matching. Based on all this facts, we can apply template matching for Object Detection/Recognition as below example.

However, there are quite much factors that limits the Template Matching to be a global method for Object Detection.

  • First of all, since we have predetermined static window size to iterate over the test image, the computer cannot detect the template object if the size of the object in the test image differs by more than a pixel with a template object.
  • Not only that, Template Matching also cannot detect the template object if it is rotated more than a degree.

These two disadvantages are called 'Scale Variant' and 'Rotation Variant'. Next time, we will take a look at revised Template Matching method with which the computer can overcome its Scale Variance.

profile
AI/ML STUDENT

0개의 댓글