title: Circle detection with OpenCV
body: <p>How can I improve the performance of the following circle-detection code</p>
  
  <pre><code>from matplotlib.pyplot import imshow, scatter, show
  import cv2
  
  image = cv2.imread('points.png', 0)
  _, image = cv2.threshold(image, 254, 255, cv2.THRESH_BINARY)
  image = cv2.Canny(image, 1, 1)
  imshow(image, cmap='gray')
  
  circles = cv2.HoughCircles(image, cv2.HOUGH_GRADIENT, 2, 32)
  x = circles[0, :, 0]
  y = circles[0, :, 1]
  
  scatter(x, y)
  show()
  </code></pre>
  
  <p>with the following source image:</p>
  
  <p><a href="https://i.stack.imgur.com/dYgHD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dYgHD.png" alt="enter image description here"></a></p>
  
  <p>I have tried adjusting the parameters of the <code>HoughCircles</code> function but they result in either too many false positives or too many false negatives. In particular, I am having trouble with spurious circles being detected in the gap between the two blobs:</p>
  
  <p><a href="https://i.stack.imgur.com/OYMlq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OYMlq.png" alt="enter image description here"></a></p>