Remove noise and detect semicircle opencv

Viewed 109

Are there ways to detect semicircle on these images?

Tried many ways and all give bad results

Example:

image = cv2.imread('path_here', 0)
output = image.copy()
ret, thresh = cv2.threshold(image, 0, 255, cv2.THRESH_OTSU)
circles = cv2.HoughCircles(thresh, cv2.HOUGH_GRADIENT, 1, 110,
                       param1=25, param2=5, minRadius=9, maxRadius=10)
detected_circles = np.uint16(np.around(circles))
for (x, y, r) in detected_circles[0, :]:
    cv2.circle(output, (x, y), r, (0, 0, 0), 2)
    cv2.circle(output, (x, y), 2, (0, 255, 255), 2)

cv2.imshow('output', output)
cv2.waitKey(0)
cv2.destroyAllWindows()
1 Answers

Alexey. I have following ideas

  1. a) You can make a fft transform of semicircle b) Make and fft transform of image and remove all that is different from semicircle fft.

  2. Try to apply Hough Circle Transform

  3. With you can load a neural network detector to detect semicircle's

cv2.dnn.readNetFromTensorFlow
# or
cv2.dnn.readNetFromTorch

With PyTorch or TensorFlow you can make a detector for this

Related