繁体   English   中英

检测非常微弱的圆圈,不清晰的边缘。 霍夫变换不起作用

[英]Detect very faint circles, not clear edge. Hough Transform not working

我正在做输出是一个微弱的大圆圈的工作。

我可以看到圆在那里,我从实验中知道它是一个均匀的实心圆。 但是我在用 python 识别它时遇到了问题。 我尝试使用霍夫变换,因为边缘不锋利,我得到了多个圆圈。 我按照下面的教程尝试使用 Canny Edge detection,但无论我使用什么 sigma 值,我都会得到非常嘈杂的结果

我也试过放大图像

https://docs.opencv.org/4.5.2/da/d53/tutorial_py_houghcircles.html

https://learnopencv.com/filling-holes-in-an-image-using-opencv-python-c/

我目前正在做的“黑客”只是徒手选择圆圈,但希望能够自动化该过程。 图片如下,如果有人能指出我正确的方向,将不胜感激!

1

归一化

自适应阈值和findContours似乎有所帮助。 模糊和阈值函数的参数需要调整您的数据,我很确定......

import cv2 as cv
from matplotlib import pyplot as plt

orig_img = cv.imread("image.png", cv.IMREAD_COLOR)

img = cv.cvtColor(orig_img, cv.COLOR_BGR2GRAY)
img = cv.normalize(img, None, 0, 255, norm_type=cv.NORM_MINMAX)
img = cv.medianBlur(img, 11)
img = cv.adaptiveThreshold(img, 255, cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY, 45, 1)
img = 255 - img
contours, hierarchy = cv.findContours(img, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
largest_contour = max(contours, key=cv.contourArea)
cv.drawContours(orig_img, [largest_contour], -1, (0, 255, 0), 2)
x, y, w, h = cv.boundingRect(largest_contour)
midx = int(x + w / 2)
midy = int(y + h / 2)
cv.circle(orig_img, (int(midx), int(midy)), max(w, h) // 2, (255, 0, 0), 2)

plt.subplot(2, 1, 1)
plt.imshow(img, cmap="gray")
plt.colorbar()


plt.subplot(2, 1, 2)
plt.imshow(orig_img)

plt.show()

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM