Document authentication using template matching with fast masked normalized cross-correlation