07-26-2010 04:00 PM
Hello
Here is an image taken by a camera.
How to find automatically the coordinates of the center of mass of my figure which is actually a kind of dumbbell. I would like to use the fact that my dumbbell has a balanced distribution in the picture.
Can someone help me with a simple VI using IMAQ or other function of Labview?
Thanks and let me know if something isn't clear.
Luckyloic
Solved! Go to Solution.
07-26-2010 04:02 PM
Sorry
I forgot to join the image in my previous message
07-26-2010 04:44 PM
Sorry for the previous mistakes
Actually I have extracted two profiles of my image: one for the rows and the other for the columns.
I would like to find the center of mass on the two attached profiles of my image.
I have already detected the peak and the valley of my row and column profile respectively.
What I would like to do now is to find the center of mass for each profile by using the area or surface method.
Thanks
07-26-2010 05:55 PM
If you want center of mass for the entire image, where the density for each pixel is equal to its intensity, use the following formula:
X = Sum (x * m) / Sum (m)
Y = Sum (y * m) / Sum (m)
Where x and y are the coordinates and m is the density (intensity). You can either do this pixel by pixel, or apply it to your profiles. You will get the same results either way.
Of course, if you want to do it the easiest way, use IMAQ Centroid. That will give you the values without needing to calculate your profiles.
The only problem with center of mass is that it includes all the background values, which will shift the centroid away from where you expect it to be. If your background values are large, it would be wise to subtract the background value before using Centroid.
Bruce
07-28-2010 01:32 PM
Hello
I used centroid and it works well. But my figure is sometimes asymetric because of the right part so the centroid is deported.
I used peak/valley detection on my profiles and it worked well also.
So now I have to work on my profiles by smoothing them with the gaussian peak fit function. My problem now is that I don't reach extracting the index values of my 1D-array called 'Y axis averages". I need that for my gaussian peak fit function as the X input.
My VI is enclosed to have a look on it.
Thanks
07-29-2010 10:09 AM
Hi,
Can you please clarify what you need when you say you don't reach extracting the index values of my 1D-array? Currently it looks like you are using the Array Max & Min VI to get the index of your Max value in the array. Is that not what you need? Are you trying to get the index value for every value in the array? If so, you could auto-index your array in a For Loop and take the iteration terminal which will return the index of the next value each iteration.
Let me know if this is not exactly what you are referring to.
07-29-2010 12:35 PM
It worked with a for loop!
Thanks