【问题标题】:How can I find the signature in an image?如何在图像中找到签名?
【发布时间】:2023-03-21 15:39:01
【问题描述】:

目前,我正在进行一个需要从医生处方中提取签名的项目。我被困在一个地方,我在 opencv 中使用轮廓来查找处方中的模式,但我不知道如何比较轮廓以匹配签名模式。

这是签名模式: Image of signature I want to find in the prescription

这是裁剪的处方: Image of the cropped prescription

在裁剪处方中使用轮廓后,我发现了以下模式: Image of contours in cropped prescription

【问题讨论】:

    标签: python opencv image-processing pattern-matching opencv-contour


    【解决方案1】:
    #import necessary packages
    import cv2
    import numpy as np
    import matplotlib.pyplot as plt
    #read the query and the template image in gray_sacle
    ref_img = cv2.imread("ref_img.jpg",0)
    template_img = cv2.imread("temp_img.jpg",0)
    w, h = template_img.shape[::-1]
    #the methods to be used for template matching
    methods = ['cv2.TM_CCOEFF_NORMED','cv2.TM_CCORR_NORMED']
    #set a threshold to qualify for a match
    threshold = 0.9
    #loop overboth the methods and do template matching
    #plot the results if the threshold is qualified
    for meth in methods:
        img = ref_img.copy()
    
        method = eval(meth)
    
        # Apply template Matching
        res = cv2.matchTemplate(img,template_img,method)
        min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
    
        top_left = max_loc
        bottom_right = (top_left[0] + w, top_left[1] + h)
    
        if max_val >= threshold:
            print(min_val,max_val)
            cv2.rectangle(img,top_left, bottom_right, 0, 2)
    
            plt.subplot(121),plt.imshow(res,cmap = 'gray')
            plt.title('Matching Result'), plt.xticks([]), plt.yticks([])
            plt.subplot(122),plt.imshow(img,cmap = 'gray')
            plt.title('Detected Point'), plt.xticks([]), plt.yticks([])
            plt.suptitle(meth)
    
            plt.show()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-09
      • 2011-05-02
      • 1970-01-01
      • 2021-01-27
      • 1970-01-01
      • 2011-08-09
      • 1970-01-01
      • 2021-07-14
      相关资源
      最近更新 更多