NormalisedCrossCorrelation.py 1.07 KB
Newer Older
Pedro TOME's avatar
Pedro TOME committed
1 2 3
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :

4 5
import numpy

Pedro TOME's avatar
Pedro TOME committed
6 7
import bob.io.base

8
from bob.bio.base.extractor import Extractor
9

Pedro TOME's avatar
Pedro TOME committed
10 11

class NormalisedCrossCorrelation (Extractor):
12 13 14 15
  """Normalised Cross-Correlation feature extractor

  Based on M. Kono, H. Ueki, and S.Umemura. Near-infrared finger vein patterns
  for personal identification. Appl. Opt. 41(35):7429-7436, 2002
Pedro TOME's avatar
Pedro TOME committed
16 17
  """

18 19 20 21 22 23 24 25 26
  def __init__(self):
    Extractor.__init__(self)


  def __call__(self, image, mask):
    """Reads the input image, extract the features based on Normalised
    Cross-Correlation of the fingervein image, and writes the resulting
    template"""

Pedro TOME's avatar
Pedro TOME committed
27
    finger_image = image    #Normalized image with histogram equalization
28 29 30 31 32 33 34 35 36
    finger_mask = mask

    image_vein = finger_image*finger_mask

    #TODO

    return image_vein.astype(numpy.float64)


Pedro TOME's avatar
Pedro TOME committed
37 38 39
  def save_feature(self, feature, feature_file):
    f = bob.io.base.HDF5File(feature_file, 'w')
    f.set('feature', feature)
40 41


Pedro TOME's avatar
Pedro TOME committed
42 43 44 45
  def read_feature(self, feature_file):
    f = bob.io.base.HDF5File(feature_file, 'r')
    image = f.read('feature')
    return (image)