Implemented various similarity measures for template matching.