我想在圖像中簡單地找到白色圓形斑點。當我嘗試用houghcircles去時,我總是把字母和數字誤認爲圈子,而我只需要完整的圈子,即斑點。無法檢測到任何白色斑點 - opencv python
所以我用自定義參數運行這個斑點檢測器代碼來找到左上角的圓形IC引腳標記。但是我一直在'9'和'0'之內得到黑眼圈。 它根本沒有檢測到任何白色斑點。
這裏是我試過的代碼:
import cv2
import numpy as np;
# Read image
img = cv2.imread("C:\chi4.jpg", cv2.IMREAD_GRAYSCALE)
retval, threshold = cv2.threshold(img, 200, 255, cv2.THRESH_BINARY)
params = cv2.SimpleBlobDetector_Params()
# Change thresholds
params.minThreshold = 10;
params.maxThreshold = 255;
blur = cv2.GaussianBlur(img,(5,5),0)
params.filterByCircularity = True
params.minCircularity = 0.2
params.filterByArea = True;
params.minArea = 1000;
ver = (cv2.__version__).split('.')
if int(ver[0]) < 3 :
detector = cv2.SimpleBlobDetector(params)
else :
detector = cv2.SimpleBlobDetector_create(params)
# Set up the detector with default parameters.
#detector = cv2.SimpleBlobDetector()
# Detect blobs.
keypoints = detector.detect(threshold)
# 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(img, keypoints, np.array([]), (0,0,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
# Show keypoints
cv2.imshow("Keypoints", im_with_keypoints)
cv2.waitKey(0)
紅色圓圈是檢測的。我想要白色的圓形斑點,在藍色的頂部被檢測到。
我試着改變閾值參數,仍然沒有影響。請讓我知道我出錯的地方或者提高產量的建議。 在此先感謝:D
您可以上傳原始圖像? –
這是原始圖像。使用USB數字顯微鏡拍攝 –