Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate a mask for centroid

I need to use the centroid vi to determine the center of mass of dots on a U8 image. For this reason i need to generate a mask.
I use "count objects 2" to find the regions of interest and then i have tried to use ROI To MASK vi to generate the masks however it does not seem to work. Could anyone help me with the mask problem?
 
The part of my program that generates the mask is called roi to mask.vi
The full program for finding centers is also attached and called Subvi centroid04.vi
 
An example image is also attached. (more vi on separate message)
 
Thanks.
Download All
0 Kudos
Message 1 of 6
(3,880 Views)
more vi's
Download All
0 Kudos
Message 2 of 6
(3,876 Views)
I think IMAQ Count Objects 2 may not be the best solution to you problem. Try using the attached vi. It thresholds and filters the image, then uses the binary particles found by thresholding as the mask for the centroid operation. This avoids noise outside the particle affecting the calculation of the centroid.

Hope that helps,
Kevin C.
National Instruments
Vision Algorithms
Message 3 of 6
(3,868 Views)

Hi Kevin

Your program seems very good, i havent had time to run it but it looks very compact.

I tried to use count objects 2 for generating the mask and then used centroid to calculate the center of each particle. When i compared the center results from count objects 2 with the ones from centroid the difference was always less than 0.15 pixels (tried 80 images with a total of 900 particles). Due to other errors in our setup i think the 0,15 difference is not a problem for us - we estimate our resolution is around 1/3 of a pixel. I will compare with your program later on and report if there is any difference.

My comparison program is attached

Thank you for your help.

Simon Viftrup

0 Kudos
Message 4 of 6
(3,856 Views)
I looked closer at your program and i must say it is very nice. However the Particle Filter 2 vi seems very advanced and the help file does not contain much information on it. Is there a manual or something for it where i can find detailed information on the different settings (espacially the connectivity and then the different selection values)?
 
Thanks
 
Simon
0 Kudos
Message 5 of 6
(3,855 Views)
Simon,

Particle Filter 2 is the function that Count Objects 2 uses internally to filter particles that are out of the specified size range (Count Objects 2 is a high-level vi that calls other Vision functions. You can examine its code if you wish). The measurements that Particle Filter 2 uses are the same as those used by Particle Analysis. The measurements are described in detail in chapter 10 of the concepts manual.

Kevin
0 Kudos
Message 6 of 6
(3,843 Views)