Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scale and rotation Template matching

I'm using the method of match template with CV_TM_CCORR_NORMED to compare two images ... I want to make to make this rotation and scale invariant .. any ideas?

I tried to use the same method on the fourier transform of the image and the template , but still the result after rotation is different

like image 918
Storm2012 Avatar asked May 19 '12 15:05

Storm2012


People also ask

Is template matching rotation invariant?

A Fast Template Matching Method for Rotation Invariance Using Two-Stage Process. Abstract: Template matching is a technique for finding the location of a reference image or an object inside a scene image. The conventional method of template matching uses cross correlation algorithms.

Which is an example of template matching?

Examples of use Template matching has various applications and is used in such fields as face recognition (see facial recognition system) and medical image processing. Systems have been developed and used in the past to count the number of faces that walk across part of a bridge within a certain amount of time.

What is template matching in signal processing?

Template matching is an approach for signal pattern recognition, often used for biomedical signals including electroencephalogram (EEG).

What is template matching in machine learning?

Template matching is a common computer vision chal- lenge where an algorithm is trying to find similarities be- tween two or more different images.


2 Answers

Rotation invariant

For each key points:

  1. Take area around key point.
  2. Calculate orientation angle of this area with gradient or another method.
  3. Rotate pattern and request area on this angle to 0.
  4. Calculate descriptors for this rotated areas and match them.

Scale invariant

See BRISK method

like image 39
George Avatar answered Sep 21 '22 01:09

George


Template matching with matchTemplate is not good when your object is rotated or scaled in scene.

You should try openCV function from Features2D Framework. For example SIFT or SURF descriptors, and FLANN matcher. Also, you will need findHomography method.

Here is a good example of finding rotated object in scene.

Update:

In short, algorithm is this:

  1. Finding keypoints of your object image 1.1. Extracting descriptors from those keypoints

  2. Finding keypoints of your scene image 2.1 Extracting descriptors from keypoints

  3. Match descriptors by matcher

  4. Analyze your matches

There are different classes of FeatureDetectors, DescriptorExtractors, and DescriptorMatches, you may read about them and choose those, that fit good for your tasks.

  • openCV FeatureDetector (steps 1 and 2 in algorithm above)
  • openCV DescriptorExtractor ( steps 1.1 and 2.1 in algorithm above )
  • openCV DescriptorMatcher ( step 3 in algorithm above )
like image 94
Larry Cinnabar Avatar answered Sep 21 '22 01:09

Larry Cinnabar