嘈杂图像中的圆圈检测 [英] circle detection in noisy a image

查看:121
本文介绍了嘈杂图像中的圆圈检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下气泡筏的图像

I have the following image of a bubble raft

这是我用来检测圆圈的代码:

Here's the code I'm using to detect the circles:

import cv2
import numpy as np
import sys

img = cv2.imread(sys.argv[1],0)
img = cv2.medianBlur(img,5)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)

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

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)
cv2.waitKey(0)
cv2.destroyAllWindows()

不幸的是,我只发现了几个圈子:

Unfortunately, I only get to detect a few circles:

我想检测图像中的大多数圆圈.由此,我可以以编程方式找到图像中央附近的错位. 任何帮助,不胜感激.预先感谢.

I'd like to detect most of the circles in the image. From that I can programmatically find the dislocation near the middle of the image. Any help much appreciated. Thanks in advance.

基于以下shortcipher3的建议,我将param2从HoughCircles降低到了15 并将最小半径增加到16,现在我可以检测到大多数圆,如下所示:

Based on the suggestion by shortcipher3 below, I lowered param2 from HoughCircles to 15 and increased the minimum radius to 16 and now I can detect most of the circles as you can see below:

推荐答案

我不清楚您的问题是什么,我想您想检测更多的圈子?

I'm not clear what your question is, I assume you want more of the circles to be detected?

HoughCircles的文档可以在这里找到:

The documentation for HoughCircles can be found here:

https://docs.opencv.org /2.4/modules/imgproc/doc/feature_detection.html?highlight=houghcircles

根据文档,我想说您的阈值在通话circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,20, param1=50,param2=30,minRadius=5,maxRadius=25)

Based on the documentation, I would say that your thresholds aren't ideal in the call circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,20, param1=50,param2=30,minRadius=5,maxRadius=25)

我首先尝试降低param2,如果对您不起作用,请尝试使用param1的值.

I would first try lowering param2 and also play with the value of param1 if that doesn't work for you.

这篇关于嘈杂图像中的圆圈检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆