Your current version will only work for binary images. It ignores the magnitude of the pixel intensity. You were more on track with the code you commented out, where you sum the numerator and denominator. Sum (i*pix) / Sum (pix) should give you the correct center of mass weighted by the pixel intensity.
I do find it interesting that the difference between your current results and the IMAQ results is always an integer value. Perhaps IMAQ is just using a different frame of reference than you expect.
Bruce
Bruce Ammons
Ammons Engineering