1. A method for recovering a warping function between a first image and a second image, comprising: constructing, for each pixel in a scan-line of a first image, a distance matrix representing distances between the pixel and a plurality of corresponding pixels of a second image, the distance matrices produced in an order of the scan-line; and determining a minimum cost path through the ordered distance matrices, the minimum cost path representing a warping function between the first image and the second image.