1. A method for correcting an error accumulated from a plurality of pair-wise registrations of image frames captured in sequence by a scanning device, comprising: using a processor to: identify a closed loop where a first image frame overlaps with a second image frame, the second image frame being captured earlier in the sequence than the first image frame; register the first image frame with the second image frame; apply a global optimization to adjust registration parameters for the plurality of pair-wise registrations of image frames within the closed loop using global constraints; identifying a registration break in the closed loop, the registration break being between two consecutive frames i and i+1 in the sequence; assigning all registration errors in the closed loop to a pair-wise registration between frames i and i+1; and updating pair-wise transformation parameters according to a transformation matrix for frames i and i+1.