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; converting the distance matrices to a directed weighted graph, in which each pixel in a scan-line of the first image corresponds to a vertex of the directed weighted graph and edges connect the vertices; 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, wherein the minimum cost path is determined by moving from an origin vertex v 1 to a destination vertex vM, where the cost C of a path p(v 1 ,vM)={v 1 ,. .. , vM} is a sum of the cost c of the edges C ⁡ ( p ⁡ ( υ 1 , υ M ) ) = ∑ x M ⁢ c ⁡ ( υ x ) , where v* is a last vertex in the path before the destination vertex vM. (original), and in which the moving from an original vertex to a destination vertex is constrained such that if a pixel at coordinate x is mapped to coordinate x*, then the consecutive pixel along the scan-line at (x+1) can be mapped to pixels at the same coordinate (x) or following pixels (>x*), but not a pixel at coordinate (x*−1) or any preceding pixel.