当前位置:   article > 正文

python指纹识别算法(亲测代码可用)_python获取小分子指纹

python获取小分子指纹

代码已测试过,可以直接使用。

  1. from os import path
  2. import math
  3. import numpy as np
  4. import cv2 as cv
  5. import matplotlib.pyplot as plt
  6. from utils import *
  7. from ipywidgets import interact
  8. fingerprint = cv.imread('samples/sample_1_1.png', cv.IMREAD_GRAYSCALE)
  9. show(fingerprint, f'Fingerprint with size (w,h): {fingerprint.shape[::-1]}')

  1. # Calculate the local gradient (using Sobel filters)
  2. gx, gy = cv.Sobel(fingerprint, cv.CV_32F, 1, 0), cv.Sobel(fingerprint, cv.CV_32F, 0, 1)
  3. show((gx, 'Gx'), (gy, 'Gy'))

Step 1: Fingerprint segmentation(指纹分割)

  1. fingerprint = cv.imread('samples/sample_1_1.png', cv.IMREAD_GRAYSCALE)
  2. show(fingerprint, f'Fingerprint with size (w,h): {fingerprint.shape[::-1]}')
Fingerprint with size (w,h): (256, 364)

  1. gx, gy = cv.Sobel(fingerprint, cv.CV_32F, 1, 0), cv.Sobel(fingerprint, cv.CV_32F, 0, 1)
  2. show((gx, 'Gx'), (gy, 'Gy'))
Gx Gy

  1. sum_gm = cv.boxFilter(gm, -1, (25, 25), normalize = False)
  2. show(sum_gm, 'Integral of the gradient magnitude')
Gx**2 Gy**2 Gradient magnitude

  1. sum_gm = cv.boxFilter(gm, -1, (25, 25), normalize = False)
  2. show(sum_gm, 'Integral of the gradient magnitude')
Integral of the gradient magnitude

  1. thr = sum_gm.max() * 0.2
  2. mask = cv.threshold(sum_gm, thr, 255, cv.THRESH_BINARY)[1].astype(np.uint8)
  3. show(fingerprint, mask, cv.merge((mask, fingerprint, fingerprint)))
<
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/346713
推荐阅读
相关标签
  

闽ICP备14008679号