From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.


Showing results for 
Search instead for 
Did you mean: 

Any examples of IMAQ Correlation

Hello Folks,

I am trying to utilize "IMAQ Correlation" VI  to correlate two near identical images. But this VI takes more than 5 minutes just to process two images of size (1280 x 1024). I need to track the position/location of various particles in an image during the course of my experiment (about 300 ~400 images).

Any help or suggestion will be greatly appreciated. Thanks.

0 Kudos
Message 1 of 13
You need to input values into the Optional Rectangle input to reduce the size of the area where the cross correlation occurs.  The only other option is to reduce the resolution of the image.  Otherwise you are probably out of luck.
Randall Pursley
0 Kudos
Message 2 of 13
Hi Randall,

Thanks for the reply. I did use the optional rectangle option, which was faster and resulted in all "white" pixels in that rectangle in final image (out). Generally, in mathematical expression - Normalized correlation gives the output between -1 to 1. So how should I intrepret the white pixels as? Will it be a right approach, if I make a template size of 50 x 50 pixel and peform the correlation analysis for a whole image using a loop? Any suggestion !!!

Basically, I am trying to understand how this IMAQ Correlation VI is working. I couldn't find much explation other than whatever is given in general help or IMAQ concept manual, which is not very clear.

Thanks Again.
0 Kudos
Message 3 of 13
What version of LabVIEW are you using?  Can you post the images?

Message Edited by rpursley8 on 03-06-2008 03:55 PM
Randall Pursley
0 Kudos
Message 4 of 13
Thanks for reply. I am using LabView 8.5.

I had attached three images and a VI which I was trying with (LV 8.0 version).

0 Kudos
Message 5 of 13
Your program seemed to work fine for me.  For your image, the point of maximum correlation should be near the center, so I change the optional rectangle to that  area and then extracted those pixels to look for the location of the maximum.  I have attached it with a few changes.

Also, there are ways to parallelize the correlation function and tile them together for a larger image.  How effective this is will depend on the PC being used.  The first step is to open up the IMAQ Correlate function and go to its properties and make it reentrant in the Execution tab.  I will try to past a parallelized version based on your images over the next couple days.

Hope this helps.
Randall Pursley
0 Kudos
Message 6 of 13
Hello Randall,

Thanks again for your help. The intensity graph is a better way to understand this. Now, if you look at the mathematical formulation of Normalized Cross-Correlation (as also given in Chapter-12 of Vision Concept Manual), the output should be in the range of (-1 to +1), where +1 value shows the highest correlation. Is this similar to the results of LabView VI, which gives the result in the range from 0 to 255, where 255 being the highest correlation?

The parallel execution method you had mentioned is new to me. So I am curious to know about this and will wait for your reply. In my experiment of the strain measurement, I will be looking at the material under observation using a rectangular mask. I have to correlate all the area witin the mask probably using a tile/facet of 30 x 30 pixel area or more depending on the speckel pattern (spray paint) size on the specimen under test. Now to speed up this process, parallel execution will be great asset. Any more suggestion/direction !!

Thanks again for all your help and will wait for your next code.

0 Kudos
Message 7 of 13
In the Help for this function, it tells you that 0 is no correlation and 255 is high correlation.
Randall Pursley
0 Kudos
Message 8 of 13
Attached is some files to compare a parallelized version versus the regular one.  I have a quad processor machine and get the following results:


32x32             575 ms         4x4 matrix of 8x8 pixel elements
64x64            2088 ms         4x4 matrix of 16x16 pixel elements
128x128          8439 ms         4x4 matrix of 323x32 pixel elements


32x32             952 ms         32x32 pixel element  
64x64            3335 ms         64x64 pixel element
128x128         13829 ms         128x128 pixel element

The parallel program returns the full optional rectangle that you can then copy to the regular program to compare times on your machine.  Make sure to make all IMAQ vis that are used in these programs Reentrant in the VI properties.
Randall Pursley
0 Kudos
Message 9 of 13
Hello Randall,

Ho Ho Ho .......... Thanks for the code. I have only single processor machine. I need some time to play and understand the code. I will write you back.

Thnaks once again.

0 Kudos
Message 10 of 13