簡體   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