0

Raw example image

I am working on a project to detect the size and number of bubbles on a surface. My current algorithm works okay, except on images that have dark blotches on them. These blotches are mistakenly selected as bubbles.

Output of current code: BAD

My current approach uses adaptive binary thresholding and canny edge detection to find the shadows of bubbles, then I find the minimum enclosing circle of each contour of the shadows. Here is an example of what the output looks like on an image without blotches:

Example of output on image without blotches

I had tried using the cv2.circle method and cv2.SimpleBlobDetector with less desirable results. Does anyone know a better way to find these bubbles... perhaps a way to detect a gradual change in the gradient rather than the sharp edges of the blotches?

Let me know if I need to clarify anything! Thank you for your advice! :)

1
  • Currently working on detecting the highlights of the bubbles rather than the shadows... the highlights seem much more subtle to me so it might not work as well, but I'll see what happens! Commented May 9, 2023 at 15:56

1 Answer 1

0

Okay, I think I figured out a way.

I found the contours that were both darker (blue) and lighter (red) than the surrounding background. Then I looped through the contours to combine red and blue contours that were close and stacked on top of each other.

Light (red) and dark (blue) contours Bubbles are circled, while ignoring dark patches.

Sign up to request clarification or add additional context in comments.

2 Comments

Please show your code.
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.