minutiaeExtract.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:Fingerprint-Recognition 作者: zhangzimou 项目源码 文件源码
def minutiaeExtract(img,imgfore):   
    """minutiae extraction: ending and bifurcation    
    img: thinned image
    imgfore: foreground image
    return: minutiae, directions
    """
    image=img.copy()
    P1=image[1:-1,1:-1]
    valid=np.where(P1==1)
    #P1:center; P2-P9:neighbors
    P1,P2,P3,P4,P5,P6,P7,P8,P9 = P1[valid],image[2:,1:-1][valid], image[2:,2:][valid], image[1:-1,2:][valid], image[:-2,2:][valid], image[:-2,1:-1][valid],image[:-2,:-2][valid], image[1:-1,:-2][valid], image[2:,:-2][valid]
    CN=pre.transitions_vec(P2,P3,P4,P5,P6,P7,P8,P9)
    ending_index=np.where(CN==1)
    bifur_index=np.where(CN==3)
    ending=np.asarray((valid[0][ending_index]+1,valid[1][ending_index]+1))
    bifur=np.asarray((valid[0][bifur_index]+1,valid[1][bifur_index]+1))
    #delete minutiae near the edge of the foreground
    imgfored=cv2.boxFilter(imgfore,-1,(9,9))
    imgfored[np.where(imgfored>0)]=255
    edge1,edge2=np.where(imgfored[ending[0],ending[1]]==255),np.where(imgfored[bifur[0],bifur[1]]==255)
    ending=np.delete(ending.T,edge1[0],0)
    bifur=np.delete(bifur.T,edge2[0],0)
    #delete minutiae near the edge of the image
    edgeDistance=20
    valid1=(ending[:,0]>=edgeDistance) * (ending[:,0]<=img.shape[0]-edgeDistance)
    valid2=(ending[:,1]>=edgeDistance) * (ending[:,1]<=img.shape[1]-edgeDistance)
    ending=ending[np.where(valid1 * valid2)]
    valid1=(bifur[:,0]>=edgeDistance) * (bifur[:,0]<=img.shape[0]-edgeDistance)
    valid2=(bifur[:,1]>=edgeDistance) * (bifur[:,1]<=img.shape[1]-edgeDistance)
    bifur=bifur[np.where(valid1 * valid2)]              
    #valide minutiae and calculate directions at the same time
    ending,theta1=validateMinutiae(image,ending,1)
    bifur,theta2=validateMinutiae(image,bifur,0)
    return ending,bifur,theta1,theta2
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号