Making Templates Rotationally Invariant. An Application to Rotated Digit Recognition