Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Error finding Center of Mass with IMAQ Vision

Hi,

I have a problem finding center of mass of a circle. Attached is an image 1) of the circle with a slant ("centerOfMass.jpg"), and 2) the circle with a smaller slant ("centerOfMass_90.jpg").

As seen on picture 1), the calculated center of mass is drifting towards the camera when moving the camera close to the circle. On picture 2), the calculated center of mass is closer to the "real" center. In picture 2) the circle is roughly close to orthogonal to the camera.

Before calculating center of mass, the circle is filled using imaqFillHoles().

What might be causing the inaccurasies in the calculations?

Thanks,
Torbjørn
0 Kudos
Message 1 of 9
(4,810 Views)
I forgot to mention: it is the largest circle with black and white sectors inside that I have problems finding correct center of mass of.

Here is the second image:
0 Kudos
Message 2 of 9
(4,808 Views)
Hi,

What is your aim in the application you have send? Are you really want to find the center of mass or center of that circle (what you have referred as real center). If you have slant image it is obvious that your center of mass will change because you changing the content of the image based on your camera location. (ie., you are increasing the blak pixels near to the your camera and reducing the black pixels which are far from your camera. If you use a center of mass, it is sure that it will shift. If your aim is to find the center of that circle, use circular edge detection and fit the elipse for that edges found, that might give a less error compare to others. For finding the edges also u can use the innermost white circle if possible. It will help in reducing the error.

Let me know your thoughts on this.

Thanks,
Logic
Message 3 of 9
(4,800 Views)
Thanks Logic,

I want to locate the "physical" center of the circle (appearing as an ellipse). I understand now that center of mass is not a good idea for finding this.

I guess I should look into circular edge detection. Do you know of a good tutorial/example on how to use this? -If possible with sorce code in C/C++ or a Vision Builder script?

The contents of the circle will change, so using the inner white circle is not an option. In many cases, the inner circle will be connected with other white sectors.

Thanks again,
Torbjørn
0 Kudos
Message 4 of 9
(4,797 Views)
I took a look at the Circular Edge tool in Vision Builder, selecting the ROI on the image. See attached image.

As you can see, the black filled circles surrounding the large circle interferes with the circular edge ROI. Is there anyway that I can remove these black circles from the calculations?

PS! The position of the circles will have random positions on the various images, so I would like some dynamic "masking" method or similar, to remove these black circles. Both size and position will alter very much. This is not a typical converyor belt application - the camera moves freely in 6 DOF.

Thanks,
Torbjørn
0 Kudos
Message 5 of 9
(4,784 Views)
Hi,

Thank you very much for the reply.
you can process your image before doing the circular edge detection. I have tried something like threshold, remove small particles so that the image is clear for you to apply the circular edge detection. Using those edges you can fit the ellipse. I have attached the VB script for this. I agree that the small circles should not merge with the big circle in order to do this.

In the fit ellipse also you can set the score and omit the points which are wrongly detected for the calculation of ellipse fitting.

6 DOF, Good application, Good luck for you.

Thanks,
Logic
Message 6 of 9
(4,777 Views)
Thanks again Logic,

I am running a earlier version of VB, so I could not use your script. However, I managed making a script of my own. I thought that the circular line detection had to use grayscale images, but since it doesn't, the part about the black circles is no longer a problem. -Thanks for that tip!

Anyway, the center of the circle reported by the circle detection tool is not very much more accurate than center of mass.

In the attached image, the red dot (zoom the image if you do not see it) represents the center found using center of mass, and the cyan/blue dot represents the center found using circle detection.

Any ideas? -Do I have to do some post-processing to get a more accurate center using circle detection?

-Thanks!
Torbjørn
0 Kudos
Message 7 of 9
(4,766 Views)
Hi,

Did u tried fitting ellipse for the circular edges found?
What i mean is by using "Find circular edge" vi you will get all the edges around the circle and it will out the circle fitted for that edges.(There is no option for the fitting the ellipse in the same VI - As i know).
So take the edges information coming out of this VI and gives as input to the "Imaq fit elipse2.vi". I hope it will fit the ellipse in a better way. If you have already done that, try adjusting the setting to that vi (score etc.,). Thats all i have. Good luck.

Thanks,
Logic
Message 8 of 9
(4,761 Views)
Thanks,

I missed the last part about "fitting ellipse". I will try that.

I am programming C/C++ in Visual Studio .NET, not using LabView. However, the functions/terms are approximately the same.

Hopefully this will make things work 🙂

Thanks once again!

Torbjørn
0 Kudos
Message 9 of 9
(4,756 Views)