Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

center of mass

Solved!
Go to solution

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

0 Kudos
Message 1 of 7
(7,650 Views)

Sorry

I forgot to join the image in my previous message

 

0 Kudos
Message 2 of 7
(7,649 Views)

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

Download All
0 Kudos
Message 3 of 7
(7,645 Views)

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

Bruce Ammons
Ammons Engineering
Message 4 of 7
(7,638 Views)

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

0 Kudos
Message 5 of 7
(7,581 Views)
Solution
Accepted by luckyloic

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.

Tejinder Gill
National Instruments
Applications Engineer
Visit ni.com/gettingstarted for step-by-step help in setting up your system.
0 Kudos
Message 6 of 7
(7,562 Views)

It worked with a for loop!

Thanks

0 Kudos
Message 7 of 7
(7,558 Views)