Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

calculate centroids(multiple) of an complex image

hi

i have a grayscale image which has 1 rectangle .I developed a VI which calculates the centroid of that rectangle object alone and not the entire image by specifying the threshold values.

but suppose i am having say 6 rectangles in that image, and i want to calculate the centorid of each of those 6 rectangles separately how do i go about it?

when i tried to use my original principle by applying the threshold values it takes the whole image , forms the threshold and gives 1 centroid.

but i want 6 centroids(each rectangle should have one centroid).

the code is working for snapimage-01 file but not for 2-seperate file.

i need to calculate 6 centroids for each of those rectangles


please advice
0 Kudos
Message 1 of 4
(3,824 Views)
the image files are attached
0 Kudos
Message 2 of 4
(3,820 Views)
other image file
0 Kudos
Message 3 of 4
(3,819 Views)
Hello Ramnath,

The centroid measurement applies to the image as a whole. It will only return one measurement. In order for it to return the "centroid" of one particular rectangle in the image, you would need to mask out all of the other rectangles. You could repeat this process for each rectangle, and obtain multiple "centroid" measurements. Creating the masks could be complex, depending on the image.

An easier approach may be to perform a Particle Analysis Report on the thresholded image. Each separate particle would return multiple measurements in the report. These measurements include the Center of Mass X and Center of Mass Y (along with others) for each particle. Keep in mind that any disconnected particle would have a report item. You may need to perform some filtering to remove "noisy" particles (such as Particle Filter to remove particles with area < 1000 or so square-pixels).

Best Regards,

Jesse Downs
Applications Engineering
National Instruments
0 Kudos
Message 4 of 4
(3,798 Views)