1. A method of correcting distortion in a digital image, said method comprising the steps of: creating a plurality of document templates; matching said digital image to one of said document templates; identifying one or more segments, wherein each segment comprises a separate distortion events in said distorted digital image; computing a formula representing each said separate distortion event; and correcting said distorted digital image by applying each said formula to its associated segment.