From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Detect and count number of balls

Hello,

 

I'm trying to develop an algorithm in Vision Builder 2013 that will detect and count the number of balls in an image.

I figure it's a hard image to work with, but the image setup cannot be changed.

 

I'm thinking the best way to start is to somehow "amplify" the edges. I've experimented with Vision Assistant where I use a combination of Erode, Median Smoothing, and Thresholding to bring out the dark edges. But it only amplifies the bottom edges because they're dark enough.

 

 

Anyone have any idea on how to proceed with this?

 

Thanks,

Hazim

 

0 Kudos
Message 1 of 3
(5,041 Views)

Hazim,

 

The best inspection step I could find is to not to use binary image processing, but just do a simple grayscale pattern match with a good template of a single ball. Using a tight template with only the circular area of the ball and a Grayscal Value Pyramid algorithm, VBAI easily found all 8 balls in your sample picture with no processing. See the attached screenshot.

Message 2 of 3
(5,008 Views)

Karl,

 

Thank you for your contribution. I tried your method and it works great, but not for all of my images (I have 100+ images to process). Not all balls have the same overall brightness or shine, and loosening the minimum score will detect the noise in the background as a false positive.

 

 

Fortunately, I've been experimenting with a sequence of filters and morphing functions, along with binary functions. I ended with +99% detection for ball-shaped objects.

 

 

But thank you again for the help.

0 Kudos
Message 3 of 3
(4,992 Views)