我正在检测斑点并对其进行图像处理(如直方图分析)。尽管我使用OpenCV SimpleBlobDetector_create(params)
检测到斑点,但是现在我想对检测到的每个斑点进行图像处理/分析。
读取灰度图像并将其存储在im
变量中之后,我编写了以下操作来检测斑点
# Setup SimpleBlobDetector parameters.
params = cv2.SimpleBlobDetector_Params()
# Change thresholds
params.minThreshold = 10;
params.maxThreshold = 200;
# Filter by Area.
params.filterByArea = True
params.minArea = 200
# Filter by Circularity
params.filterByCircularity = True
params.minCircularity = 0.30
# Filter by Convexity
params.filterByConvexity = True
params.minConvexity = 0.5
# Filter by Inertia
params.filterByInertia = True
params.minInertiaRatio = 0.001
#now let us do blob analysis
#Set up the detector with default parameters.
detector = cv2.SimpleBlobDetector_create(params)
#Detect blobs.
keypoints = detector.detect(im)
im_with_keypoints = cv2.drawKeypoints(im, keypoints, np.array([]), (0,0,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
这给出了以下图像:
Output Image After Blob Detection
据我了解,cv2.SimpleBlobDetector_create(params)
输出关键点。每个关键点的变量类型为cv2.keypoint
。我试图了解here的关键点,但是并没有太大帮助。如果有人向我展示如何分析关键点(或本例中为斑点)内区域的方向(例如直方图分析等图像处理),我将不胜感激。