Detection and Rectification of Distorted Fingerprints