Calculates shifts of the row of images