A computer-implemented method of transforming a first image to bring it closer to alignment with a second image, the method comprising: implementing a multiple kernel tracking technique to determine positions of a set of candidate regions of the first image based on a similarity between a set of target regions of the second image and the set of candidate regions of the first image by iteratively optimizing the similarity between feature histograms of the set of target regions and corresponding feature histograms of the set of candidate regions by iteratively varying the positions of the candidate regions, wherein the target regions of the second image are respectively positioned over the positions of a predetermined set of points of the second image; using some of the determined positions of the set of candidate regions to initialize a Lucas Kanade Inverse algorithm, comprising discarding a candidate region that has a feature histogram calculated by said multiple kernel tracking technique, which indicates that the candidate region is flat; using the Lucas Kanade Inverse algorithm to determine a set of points of the first image which correspond to at least some of the predetermined set of points of the second image; determining parameters of a transformation to be applied to the first image based on an error metric which is indicative of an error between a transformation of at least some of the determined set of points of the first image and the corresponding points of the predetermined set of points of the second image; and applying the transformation to the first image to bring it closer to alignment with the second image, wherein said discarding a candidate region that has a feature histogram indicating that the candidate region is flat comprises determining that the feature histogram indicates that the candidate region is flat by: setting a weight for the candidate region to zero; reading the bins of the feature histogram to determine the weight for the candidate region, wherein for each bin, i, of the feature histogram: if the i th bin is not zero then: (a) the weight for the candidate region is incremented, and (b) if the (i-1) th bin is zero then the weight for the candidate region is incremented again; wherein the candidate region is determined to be flat if the weight for the candidate region is lower than four. implementing a multiple kernel tracking technique to determine positions of a set of candidate regions of the first image based on a similarity between a set of target regions of the second image and the set of candidate regions of the first image by iteratively optimizing the similarity between feature histograms of the set of target regions and corresponding feature histograms of the set of candidate regions by iteratively varying the positions of the candidate regions, wherein the target regions of the second image are respectively positioned over the positions of a predetermined set of points of the second image; using some of the determined positions of the set of candidate regions to initialize a Lucas Kanade Inverse algorithm, comprising discarding a candidate region that has a feature histogram calculated by said multiple kernel tracking technique, which indicates that the candidate region is flat; using the Lucas Kanade Inverse algorithm to determine a set of points of the first image which correspond to at least some of the predetermined set of points of the second image; determining parameters of a transformation to be applied to the first image based on an error metric which is indicative of an error between a transformation of at least some of the determined set of points of the first image and the corresponding points of the predetermined set of points of the second image; and applying the transformation to the first image to bring it closer to alignment with the second image, wherein said discarding a candidate region that has a feature histogram indicating that the candidate region is flat comprises determining that the feature histogram indicates that the candidate region is flat by: setting a weight for the candidate region to zero; reading the bins of the feature histogram to determine the weight for the candidate region, wherein for each bin, i, of the feature histogram: if the i th bin is not zero then: (a) the weight for the candidate region is incremented, and (b) if the (i-1) th bin is zero then the weight for the candidate region is incremented again; setting a weight for the candidate region to zero; reading the bins of the feature histogram to determine the weight for the candidate region, wherein for each bin, i, of the feature histogram: if the i th bin is not zero then: (a) the weight for the candidate region is incremented, and (b) if the (i-1) th bin is zero then the weight for the candidate region is incremented again; wherein the candidate region is determined to be flat if the weight for the candidate region is lower than four.