Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Center of mass of an entire blob array

Hi guys,

 

I have an image with severyl blobs that form an (non-perfect) array. I need to find the center of mass of the entire image (not single blobs, I know how to do that already). The image is binary since I extracted a color plane.

Could someone please help me out?

 

Thanks!

0 Kudos
Message 1 of 5
(5,100 Views)

Hello,

 

it should be as simple as this:

 

u_center = sum(mi * ui) / sum (mi)

v_center = sum(mi * vi) / sum (mi)

 

Assuming each pixel has equal weight:

 

Example_VI_BD.png

 

What is a non-perfect array?

 

If you detected the central masses of individual blobs, perhaps you could use only the detected positions for your global calculation?

 

Best regards,

K

 


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 2 of 5
(5,039 Views)

Thanks for your reply! Non-perfect means the position of the blobs may deviate from a perfect orthogonal grid. I should add that the blobs are on a display and their brightness decreases from the center outwards, so there is a gradient and no abrupt cut like if I draw a white circle on a black background in paint for example.

In the mean time I found the centroid function in the vision development module which seems to do exactly what I need.

 

But now I have a different problem:

I detect the blobs using a fixed threshold (brightness value in an 8-bit grey scale image, so 0...255) which results in unpredictable behavior when applying the threshold to images with different brightness values for the pixels:

If the threshold is too high, it detects not

 

I talked to a colleague and he suggested I rather use a circle or square detection method (depending on the blob geometry) where I can use a parameter for the gradient of the transition between bright and dark (in darker areas the algorithm should look more closely in order to find the blobs). The vision development module has the function "detect circular edge" with an "edge strength" parameter, but I don't know how I could call that function as many times as I have blobs.

In the vision assistant I can draw an ROI and inside that position the circular edge detector manually - but I never know where exactly the blobs are. The detector would have to scan the whole image and return the results. Is there a way to do that automatically?

The second possibility is the "IMAQ find circles" VI, but there I cannot control the edge strength?

 

Thanks!

 

P.S.

I attached an example image with the blob array

0 Kudos
Message 3 of 5
(5,018 Views)

Hello,

 

your grid seems pretty well contrasted. Have you seen the adaptive threshold method - try background correction method? After this, you can additionally use some morphology operators to filter the potential noise.

 

Can you ttach another image with "different brightness values" as you've said.

 

Also, note that the centroid function also uses pixel weights (not a problem, if your image is binary). Basically the same as I've posted above, just the mi != 1.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 4 of 5
(5,005 Views)

Hi,

From what I understand, you somehow want to be able to combine all the blobs together and then find out the center of mass of the resultant particle.

This should be possible in this case. After seeing your image I think the best way to do this would be as follows:

1) Threshold the image- should be easy as there is a good amount of contrast between the background and the object of interest.

2) run a particle analysis and compute the bounding box of all particles.

3) The bounding box(BB) of the combined particle(CP)(the big particle that comprises all the small ones) can be found using the bounding box of the individual particles. The BB left of CP is the smallest left value among all the BB left of the individual particles. Similar logic can be used to get the BB right ,top and bottom of CP. Then use rectangle to ROI to get the ROI of CP. Convert the ROI to mask to obtain a mask of CP. Use particle analysis to get the final center of mass of CP. 

0 Kudos
Message 5 of 5
(4,911 Views)