1
這是我的代碼,並通過使用此代碼亮點完美檢測如圖所示。但問題是即使現場不存在它會檢測圖像中的虛假斑點可以幫助我如何擺脫這個?如何避免虛假亮點檢測?
# import the necessary packages
import numpy as np
import argparse
import cv2
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", help = "Desktop")
ap.add_argument("-r", "--radius", type = int,
\t help = "radius of Gaussian blur; must be odd")
args = vars(ap.parse_args())
# load the image and convert it to grayscale
image1 = cv2.imread("h.png")
orig = image1.copy()
gray = cv2.cvtColor(image1, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray, (args["radius"], args["radius"]), 0)
(minVal, maxVal, minLoc, maxLoc) = cv2.minMaxLoc(gray)
image1 = orig.copy()
cv2.circle(image1, maxLoc, args["radius"], (255, 0, 0), 2)
# display the results of our newly improved method
cv2.imwrite("myImage.png", image1)
[1]: https://i.stack.imgur.com/6CDYP.png
非常感謝你爲ZdaR您寶貴的建議,我會嘗試,讓你知道 –
即使我使用的檢測閾值假斑點@ ZdaR..what我可不可以做?? –
你可以給你的郵件編號,我會詳細告訴你我是'[email protected]' –