使用python进行图像处理检测图像中的点

问题描述

我需要识别给定图像中的以下点。但它没有给出正确的检测。有人可以提供一种方法来识别这样的图像中的这些点吗?

enter image description here

我对此做了一些改进,如下所示, {{3}}

  • 增强图像,先膨胀再锐化

    我使用模板匹配来检测图像中的这些点。但效果并不好。代码如下。有没有其他方法可以检测到这些?

导入 cv2 将 numpy 导入为 np

sedDual = list_of_spinner[position].toString()

解决方法

这是我快速开发的代码的主要部分,以获得更好的结果(如下图所示):

import cv2 as cv
img = cv.imread('med.jpg',0)
th2 = cv.adaptiveThreshold(img,255,cv.ADAPTIVE_THRESH_MEAN_C,\
            cv.THRESH_BINARY,11,2)
th3 = cv.adaptiveThreshold(img,cv.ADAPTIVE_THRESH_GAUSSIAN_C,2)
titles = ['Adaptive Mean Thresholding','Adaptive Gaussian Thresholding']
images = [th2,th3]
inv = ~th3
res = cv.bitwise_and(img,inv)
cv.imshow(titles[1],res)
cv.waitKey(0)
cv.imwrite("result.jpg",res)
cv.destroyAllWindows()

enter image description here

调整参数以获得所需的结果。