2

I am writing a program with OpenCV that detects circles in the structure pictures. I'm using the Watershed method described here.

There is a problem I faced: 3d structure photo is hardly converted into a binary picture (due to shadows and different depth), so the program can't spot circles. Here you can see my best results of processing 3d structures (2d are detected perfectly).

original

binary

processed

So, is there any way to process pictures of 3d structure and make it possible to convert it into an acceptable bin picture and process with watershed? Maybe I should use a completely different method?

My code:

import cv2
import numpy as np

im = cv2.imread('spheres1.bmp')
hsv = cv2.cvtColor(im, cv2.COLOR_BGR2HSV)
hsv_min = np.array((0, 0, 110), np.uint8)
hsv_max = np.array((0, 0, 255), np.uint8)
gray = hsv[:, :, 2]
gray = cv2.inRange(hsv, hsv_min, hsv_max)

bw = cv2.medianBlur(gray, 13)

#then I use Watershed algorithm
5
  • 2
    that is an electron microscopy image, just to state the obvious. -- that is a tough picture to work with. no sharp edges, generally noisy, bubbles of varying size and shape, occluding each other... -- "cheap" methods won't work here. especially not anything presented in random blogs/youtube tutorials addressed to newbies. -- when in doubt, use AI. maybe instance segmentation could be trained to label each of these bubbles. Commented Dec 29, 2021 at 22:19
  • Actually, the main goal of my program is not the spheres detection, I am just trying to save expert's time on matching structures. How many samples you think it is required to train and test AI with this method? Commented Dec 30, 2021 at 3:47
  • can't say. dozens perhaps, depending on the network and if it's just tuned ("transfer learning") or trained from scratch (would be unreasonable). Commented Dec 30, 2021 at 3:53
  • Have you tried Hough circles? It may be able to do better at detecting circles in the background. Commented Dec 30, 2021 at 18:23
  • Yes, that was the first i've tried. It doesn't spot them due to overlays. Commented Dec 30, 2021 at 18:44

0

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.