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).
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