Face recognition template matching algorithm