Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I properly use imaqCentroid() ?

Hi,

Earlier, I used particle filtering and imaqCalcCoeff(IMAQ_CENTER_MASS_X, Y) to find the center of mass of a black circle printed on a white piece of paper.

Then I would like to try to calculate the center-position using the grayscale image, to achieve sub-pixel accuracy.

I have tried running imaqCentroid() on the image, with a mask surrounding the black circle (the ROI is set to a few pixels larger than the binary particle found at same position).

But the results from imaqCentroid() is much worse than when using blob/particle analysis. The center position is quite different, and there is much more jittering.

I suspect that I need to modify my grayscale image before running imaqCentroid(), but I am not sure which st
eps/functions to use.

Comments?

Thanks,
Torbjørn
0 Kudos
Message 1 of 3
(3,205 Views)
Try a white circle on a black background. It will work better. Another option is to invert your current image.

The white pixels carry the most weight (255) when using IMAQ Centroid. The black pixels carry the least weight (0). Right now, you are calculating the centroid of the white strip around your circle. By inverting the image, you will calculate the centroid of the circle.

The best results for IMAQ Centroid are obtained with a white object on a black background. If the lighting is not even or the color/brightness is not even, you will get shifts in your centroid away from the actual center.

I think your results with blob analysis will be better and more consistant than IMAQ Centroid. Another option, if your blobs are all circles, is to us
e Find Circular Edge once you know their approximate location. This uses edge finding to very accurately determine the position of a circular object.

Bruce
Bruce Ammons
Ammons Engineering
Message 2 of 3
(3,205 Views)
Thank you once again, Bruce 🙂 Your answers are very helpful!

I will try both inverting my image and using Find Circular Edge and see how it looks. My blobs are circles in real life, thus ellipses in the image plane. (does Find Circular Edge deal with ellipses?)

My application makes it a bit hard to use white circles on black background, but I guess I should test this as well.

Best regards,
Torbjørn
0 Kudos
Message 3 of 3
(3,205 Views)