虹膜识别--mask的生成

本文深入探讨虹膜识别技术,重点介绍如何生成虹膜识别中的关键元素——mask。通过理解虹膜的生物特征,阐述从图像预处理到mask生成的过程,包括图像增强、定位、分割等步骤,揭示虹膜识别的高效与准确性。
摘要由CSDN通过智能技术生成
import numpy as np
from Segmentation import IrisLocalization
from line import findline, linecoords
import multiprocessing as mp


##-----------------------------------------------------------------------------
##  Function
##-----------------------------------------------------------------------------
def segment(eyeim, eyelashes_thres=80, use_multiprocess=True):
ciriris,cirpupil = IrisLocalization(eyeim)
   row = np.round(ciriris[0]).astype(int)
   col = np.round(ciriris[1]).astype(int)
   r = np.round(ciriris[2]).astype(int)
   rowp = np.round(cirpupil[0]).astype(int)
   colp = np.round(cirpupil[1]).astype(int)
   rp = np.round(cirpupil[2]).astype(int)
   # Find top and bottom eyelid
   imsz = eyeim.shape
   irl = np.round(row - r).astype(int)
   iru = np.round(row + r).astype(int)
   icl = np.round(col - r).astype(int)
   icu = np.round(col + r).astype(int)
   if irl < 0:
      irl = 0
   if icl < 0:
      icl = 0
   if iru >= imsz[0]:
      iru = imsz[0] - 1
   if icu >= imsz[1]:
      icu = imsz[1] - 1
   imageiris = eyeim[irl: iru + 1, icl: icu + 1]

   # If use_multiprocess
   if use_multiprocess:
      ret_top = mp.Manager().dict()
      ret_bot = mp.Manager().dict()
      p_top = mp.Process(
         target=findTopEyelid,
         args=(imsz, imageiris, irl, icl, rowp, rp, ret_top),
      )
      p_bot = mp.Process(
         target=findBottomEyelid,
         args=(imsz, imageiris, rowp, rp, irl, icl, ret_bot),
      )
      p_top.start()
      p_bot.start()
      p_top.join()
      p_bot.join()
      mask_top = ret_top[0]
      mask_bot = ret_bot[0]

   # If not use_multiprocess
   else:
      mask_top = findTopEyelid(imsz, imageiris, irl, icl, rowp, rp)
      mask_bot = findBottomEyelid(imsz, imageiris, rowp, rp, irl, icl)

   # Mask the eye image, noise region is masked by NaN value
   imwithnoise = eyeim.astype(float)
   imwithnoise = imwithnoise + mask_top + mask_bot
   ref = eyeim < eyelashes_thres
   coords = np.where(ref == 1)
   imwithnoise[coords] = np.nan
   return ciriris, cirpupil, imwithnoise


#------------------------------------------------------------------------------
def findTopEyelid(imsz, imageiris, irl, icl, rowp, rp, ret_top=None):
   """
   Description:
      Mask for the top eyelid region.

   Input:
      imsz      - Size of the eye image.
      imageiris  - Image of the iris region.

      irl           -
      icl           -

      rowp      - y-coordinate of the inner circle centre.
      rp        - radius of the inner circle centre.

      ret_top       - Just used for returning result when using multiprocess.

   Output:
      mask       - Map of noise that will be masked with NaN values.
   """
   topeyelid = imageiris[0: rowp - irl - rp, :]
   lines = findline(topeyelid)
   mask = np.zeros(imsz, dtype=float)

   if lines.size > 0:
      xl, yl = linecoords(lines, topeyelid.shape)
      yl = np.round(yl + irl - 1).astype(int)
      xl = np
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值