Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How does the "MatchPattern2" method work internally?

Hi,

 

we are using the function "MatchPattern2" of NI Vision 8.5 in a C#/ NET3.5 environment on WinXP SP2. The images we are using have been created manually. So they have perfect edges/transitions from black and grey values to white and vice versa.In addition there is no noise on the images. We are wondering about some deviations (pattern match result <-> expected result).

 

First we find a symetric template inside the image from which we have extracted it. Afterwards we rotate the template by 180° and repeat the match process. While first match operation yields the expected results with no "odd" decimals (<x>.500, <y>.500), the result of the second match operation is something like (<x>.49877, <y>.50321). Since the image and template dimensions (width/height: 40.0px)  also have no decimals, I would have expected, that the second match also has (<x>.500, <y>.500) as result.

 

As far as I understand, pattern recognition using this algorithm is by default done in frequency domain via FFT and NOT in spatial domain using "Normalized Cross-Correlation". This could be a reason for the deviation I mentioned above.

 

Is there any way to configure "MatchPattern2" to use spatial domain correlation during the detection process?

If no, is there another algorithm which can be configured like this?

 

Furthermore we'd like to ask, if there is a way to obtain a 2D representation of the pattern match result function (correlation values for the whole image)? "CWIMAQPatternMatchReport" only contains information about an actual match at a certain point.

 

Thanks in advance

0 Kudos
Message 1 of 4
(3,512 Views)

Here are the images we're using.

 

For some reason we rotate the original image (7050_3_4_l.jpg) 90° CCW before extraction/matching

 

Log output of our application:

 

Extracting template with [L/T/W/H] (5,15,40,40)

 

Found extracted template image at pixel position <(24.5/34.5)> - corr: <1000>

-> rotate template image 

Found rotated template image at pixel position <(24.5110492706299/34.9149360656738)> - corr: <990.426452636719>

Download All
0 Kudos
Message 2 of 4
(3,503 Views)
The image that you have attached is a 40x40. Is that what you are using?
0 Kudos
Message 3 of 4
(3,499 Views)

Hi,

 

(Template_*.jpg) are both just some kind of memory dump during our image processing procedure. They are NOT loaded as files and used for pattern matching afterwards. Their only purpose is to visualize, with which data our algorithm is working at certain points.

 

The original image is (7050_3_4_l.jpg / 70x50) from which I extract the template (Template_Extracted.jpg / 40x40) using an offset of  (5 left / 15 top) after rotating the original image 90° CCW.

 

In the next step, I trigger pattern matching using this template. As result I get the center of the template in the image coordinate system.That is what I expect.

 

After this I rotate the extracted image by 180° resulting in (Template_Rotated.jpg / 40x40).

 

The problem I have is, that the pattern match using the rotated template should yield also a result like <x>.500 and <y>.500, at least if the grey values at the left and right edge of the rectangle are identical (symetric template). But the results are slightly different.

 

We assume that this difference could be caused by using frequency domain pattern matching instead of spatial domain.

Sorry, I attached an image containing a non-symetric template. But it is not so crucial, since the most important thing for us is to know,

  - how the pattern detection works internally and if it uses spatial or frequency domain.

  - how we can "force" usage of spatial domain

 

Thanks in advance

 

 

 

0 Kudos
Message 4 of 4
(3,485 Views)