【发布时间】:2017-05-25 17:59:37
【问题描述】:
这是我拥有的代码,通过使用此代码,可以完美检测到亮点,如图所示。但是,问题是即使该点不存在enter image description here,它也会检测到图像中的错误点可以提供帮助我怎么摆脱这个???
# 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,
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
【问题讨论】:
标签: python-3.x opencv