I am trying to detect all the circles in the array. To achieve this I am using Hough Circle Transform. I am able to detect 100% circles in the array but there are a lot many false positives and when I get rid of the false positives I am not able to detect 100% circles. When I change the dp parameter to 1 in the code given below then all the false positives are gone and when I keep it as 3 then there are many false positives with 100% detection. I would like to get 100% detection with 0 or very few false positives. What would be the best approach to do this.
import cv2
import cv2.cv as cv
import numpy as np
img = cv2.imread('test1.tiff',0)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
circles = cv2.HoughCircles(img, cv.CV_HOUGH_GRADIENT,3,15,
param1=70 ,param2=17,minRadius=1,maxRadius=10)
circles = np.uint16(np.around(circles))
for i in circles[0,:]:
# draw the outer circle
cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2)
cv2.imshow('detected circles',cimg)
cv2.imwrite("output15.jpg", cimg)
cv2.waitKey(0)
cv2.destroyAllWindows()
Here there is a sample image:
img = cv2.imread('test1.tiff',0) cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
isn't it already a color image?? – Яois