【发布时间】:2016-08-16 16:02:40
【问题描述】:
我在以下网站获得了blob检测程序:https://www.learnopencv.com/blob-detection-using-opencv-python-c/
它非常有用,但我发现更改参数值后结果没有任何变化。 比如:即使我将颜色的参数设置为 255(它用于检测较浅的斑点),仍然可以检测到深色的斑点。另外,我改变最小面积的值后,也可以检测到最小的斑点。
似乎没什么变化,结果总是如下: the result of blob detection 代码如下:
import cv2
import numpy as np;
# Read image
im = cv2.imread("blob.jpg", cv2.IMREAD_GRAYSCALE)
# Set up the detector with default parameters.
detector = cv2.SimpleBlobDetector()
params = cv2.SimpleBlobDetector_Params()
# Change thresholds
params.minThreshold = 10; # the graylevel of images
params.maxThreshold = 200;
params.filterByColor = True
params.blobColor = 255
# Filter by Area.
params.filterByArea = False
params.minArea = 10000
# Detect blobs.
keypoints = detector.detect(im)
# 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(im, keypoints, np.array([]), (0,0,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
# Show keypoints
cv2.imshow("Keypoints", im_with_keypoints)
cv2.waitKey(0)
谁能帮帮我?非常感谢!!!
【问题讨论】: