title: OpenCV Simple Blob Detector not detecting all blobs
body: <p>I am trying to port one of my image analysis scripts from Mathematica to Python OpenCV, but I am having trouble with one of the functions involved. </p>
  
  <p>I managed to binarise and watershed the image, much like one does in Mathematica. However, the steps to filter the properties of the connected components seem to be not working correctly. </p>
  
  <p>The input image is below:</p>
  
  <p><a href="https://i.stack.imgur.com/YUSAQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YUSAQm.png" alt="Input image"></a></p>
  
  <p>However, I attempted to run the following code:</p>
  
  <pre><code>import cv2
  import numpy as np
  
  img = cv2.imread('test2.4.png', 1)
  img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  
  # Set up the detector and configure its params.
  params = cv2.SimpleBlobDetector_Params()
  params.minDistBetweenBlobs = 0
  params.filterByColor = True
  params.blobColor = 255
  params.filterByArea = True
  params.minArea = 10
  params.maxArea = 300000
  params.filterByCircularity = False
  params.filterByConvexity = False
  params.filterByInertia = True
  params.minInertiaRatio = 0.01
  params.maxInertiaRatio = 1
  detector = cv2.SimpleBlobDetector_create(params)
  
  # Detect blobs.
  keypointsb = detector.detect(img)
  
  # Draw detected blobs as red circles.
  im_with_keypoints = cv2.drawKeypoints(img, keypointsb, np.array([]), (0,0,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
  
  # Show keypoints
  cv2.imwrite('test3.png',im_with_keypoints)
  </code></pre>
  
  <p>As seen in the code, I have set the parameters for the blob detection to be as permissive as possible. However, a large proportion of the blobs are not detected, and none of the watershed-split blobs were detected either. </p>
  
  <p>I have checked the <a href="http://docs.opencv.org/2.4/modules/features2d/doc/common_interfaces_of_feature_detectors.html#simpleblobdetector" rel="nofollow noreferrer">documentation for the function</a> and tweaked most of them with the exception of thresholds and <a href="https://stackoverflow.com/questions/32973537/what-is-the-use-of-minrepeatability-parameter-of-simpleblobdetector-in-opencv">repeatability</a> (as the image is already binarised). Is there any other configuration that I should perform in order for the function to detect all of the blobs present?</p>
  
  <p><a href="https://i.stack.imgur.com/phyZN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/phyZNm.png" alt="enter image description here"></a></p>
  
  <p>Alternatively, are there any other recent/well updated libraries that are capable of filtering by component measurements?</p>