LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

formula using while loop

I am developing a program which will calculate the correlation co-efficient between two pictures. I have two input arrays from flattening pictures, which I then manipulate in a while loop using a formula node.
I am somehow getting incorrect results and I dont konw why. the formula for r is standard where r=Sum(A-Amean)*(B-Bmean)/sq root[(Sum(A-Amean)^2)*(Sum(B-Bmean)^2)]
A and B are the individual values or the array, Amean and Bmean are the mean values of the array.
I think I may be working out the sum of the values incorrectly. Can anyone help.
I have included the program i have written and two images i am trying to insert. The expected value is 0.96

Please help!
Download All
0 Kudos
Message 1 of 2
(3,139 Views)
Your problem is that you initialize the shift register to zero within the subroutine, meaning it will get reset with every iteration of the FOR loop.

You need to put the shift register on the border of the for loop. However, you can use straight "wire math" to do the entire thing much more efficiently and without any loops and formula nodes. See attached rough modification (please verify correct operation, I have not fully debugged it).
Message 2 of 2
(3,139 Views)