Number detection using thresholding and template matching