An Algorithm for Pattern Extraction in Fingerprints