【问题标题】:Robust and automatable droplet fitting强大且可自动化的液滴拟合
【发布时间】:2018-07-01 15:43:05
【问题描述】:

我正在尝试对一组灰度图像执行图像分析,如下图所示:

主要目标是能够测量椭圆液滴的尺寸并确定它们的中心坐标。 我已经在 openCV 和 scikit-image 中尝试了 Hough Circular Transform。与 openCV 相比,到目前为止我看到的所有 scikit-images 示例的运行速度都非常慢。

我在这段代码中取得了一定的成功(取自示例):

img = read_img[600:,:]
img = cv2.medianBlur(img,5)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)

circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,30,
            param1=45,param2=20,minRadius=1,maxRadius=45)

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)
    # draw the center of the circle
    cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)

cv2.imshow('detected circles',cimg)
fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(20, 20))
ax.imshow(cimg)

检测到主要液滴,但未能捕捉到三个较小的液滴。

我能够构建的最佳阈值是使用 openCV 的这些参数

th2 = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_MEAN_C,\cv2.THRESH_BINARY,15,5)

但是,我仍然无法使用上面的代码找到较小的液滴。

我有几千张图像要处理。我需要算法能够自动找到变换或阈值的最佳参数。到目前为止,我不知道如何实现这样的东西。

任何有关正确实施的建议将不胜感激!

【问题讨论】:

  • 第三个小水滴到底在哪里?
  • 从左边数第四个大圆环上方有一系列 3 个卫星液滴
  • 我在执行自适应阈值后注意到了。如果有帮助,请参阅下面的答案。

标签: python opencv image-processing geometry scikit-image


【解决方案1】:

我只是提出了一个可能的预处理步骤,而不是一个完整的解决方案。您可以在图像的绿色通道上执行adaptive thresholding

代码:

img = cv2.imread('C:/Users/Jackson/Desktop/droplet.jpg', 1)

#--- Resized the image to half of its original dimension --
img = cv2.resize(img, (0, 0), fx = 0.5, fy = 0.5)

#--- I narrowed down to these values after some rigorous trial-and-error ---
th3 = cv2.adaptiveThreshold(img[:,:,1], 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C,\
            cv2.THRESH_BINARY, 63, 5)

cv2.namedWindow('Original', 0)
cv2.imshow('Original', img) 
cv2.namedWindow('th3', 0)
cv2.imshow('th3', th3)         
cv2.waitKey()
cv2.destroyAllWindows()

结果:

你可以从这里继续。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-18
    • 1970-01-01
    • 2023-01-14
    • 1970-01-01
    • 1970-01-01
    • 2020-02-21
    相关资源
    最近更新 更多