Matching algorithm working for offline images