1. A computer-based method for compensating for affine distortions in handwriting recognition, comprising: performing orientation estimation on a handwriting sample (sample) using a computer-based processor to yield a set of likely characters for the sample; determining an estimated affine transform for the sample by applying a hidden Markov model (HMM) based minimax testing to the sample using the set of likely characters; and compensating for affine distortions of the sample by applying the estimated affine transform to the sample.