NormalisedCrossCorrelation.py 1.28 KB
Newer Older
Pedro TOME's avatar
Pedro TOME committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Pedro Tome <Pedro.Tome@idiap.ch>

import bob.core
import bob.io.base

import numpy
from facereclib.features.Extractor import Extractor

class NormalisedCrossCorrelation (Extractor):
  
  """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
  """

  def __init__(
      self,
            
  ):

    # call base class constructor
    Extractor.__init__(
        self,
        
    )
    
    # block parameters
  
  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"""
    
    finger_image = image    #Normalized image with histogram equalization
    finger_mask = mask   

    image_vein = finger_image*finger_mask        
   
    #TODO	
    
    return image_vein.astype(numpy.float64)  
        
  def save_feature(self, feature, feature_file):
    f = bob.io.base.HDF5File(feature_file, 'w')
    f.set('feature', feature)
            
  def read_feature(self, feature_file):
    f = bob.io.base.HDF5File(feature_file, 'r')
    image = f.read('feature')
    return (image)