I have created a black and white mask using various OpenCV filters. There are four circles that are clearly visible
I am trying to outline these circles using HoughCircles, but it gives many false positives and generally bad results:
circles = cv2.HoughCircles(combined, cv.CV_HOUGH_GRADIENT, 1, 300, np.array([]), 10, 30, 60, 300)
How can I properly detect the circular shapes in the black and white image?
Here is runnable code that can be used with the black and white image:
import numpy as np
import cv2
import cv
image = cv2.imread("image.png")
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
circles = cv2.HoughCircles(gray, cv.CV_HOUGH_GRADIENT, 1, 300, np.array([]), 10, 30, 60, 300)
if circles is not None:
circles = np.uint16(np.around(circles))
for i in circles[0,:]:
cv2.circle(image, (i[0], i[1]), i[2], (0, 255, 0), 1)
cv2.circle(image, (i[0], i[1]), 2, (0, 0, 255), 3)
cv2.imshow("thing", image)
cv2.waitKey(0)
cv2.destroyAllWindows()