<blockquote>
<p>Since you are open to OpenCV approaches you could use a
<code>SimpleBlobDetector</code></p>
</blockquote>
<p>显然,我得到的结果也不是完美的,因为有很多超参数需要设置。超参数使它非常灵活,所以它是一个不错的起点。在</p>
<p>{这是探测器做什么的细节}:</p>
<ol>
<li><strong>阈值化</strong>:通过对源图像进行阈值化,将源图像转换为多个二进制图像。这些阈值递增<code>thresholdStep</code>,直到<code>maxThreshold</code>。所以第一个阈值是<code>minThreshold</code>,第二个阈值是<code>minThreshold + thresholdStep</code>,第三个阈值是{<cd5>},依此类推。在</li>
<li><strong>分组</strong>:在每个二值图像中,连接的白色像素被分组在一起。我们把这些二进制水滴称为。在</li>
<li><p><strong>合并</strong>:计算二值图像中二进制斑点的中心,并合并位于<code>minDistBetweenBlobs</code>附近的斑点。</p></li>
<li><p><strong>中心和半径计算</strong>:计算并返回新合并水滴的中心和半径。</p></li>
</ol>
<p><em>找到图片下方的代码。</em></p>
<p><a href="https://i.stack.imgur.com/rc0mW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rc0mW.jpg" alt="Output Image"/></a></p>
<pre><code># Standard imports
import cv2
import numpy as np
# Read image
im = cv2.imread("petri.png", cv2.IMREAD_COLOR)
# Setup SimpleBlobDetector parameters.
params = cv2.SimpleBlobDetector_Params()
# Change thresholds
params.minThreshold = 0
params.maxThreshold = 255
# Set edge gradient
params.thresholdStep = 5
# Filter by Area.
params.filterByArea = True
params.minArea = 10
# Set up the detector with default parameters.
detector = cv2.SimpleBlobDetector_create(params)
# Detect blobs.
keypoints = detector.detect(im)
# Draw detected blobs as red circles.
# cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures the size of the circle corresponds to the size of blob
im_with_keypoints = cv2.drawKeypoints(im, keypoints, np.array([]), (0, 0, 255),
cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
# Show keypoints
cv2.imshow("Keypoints", im_with_keypoints)
cv2.waitKey(0)
</code></pre>