1. An image processing apparatus, comprising: a processor; and a memory storing instructions that, when executed by the processor, cause the image processing apparatus to: obtain a plurality of pairs of a feature point in the first image and a feature point in the second image, wherein the pair of feature points are selected such that local feature amounts of the images at the feature points are similar; count at least one of the number of feature points in the first image where local feature amounts are similar to a local feature amount at one of the pair or the number of feature points in the second image where local feature amounts are similar to a local feature amount at one of the pair and set an evaluation for each of the pairs based on the counted number of feature points such that the smaller the counted number of feature points, the higher the evaluation; and determine a similarity between the first image and the second image using a random sample consensus (RANSAC) method, wherein a selected pair having a high evaluation is used with priority and an unselected pair is excluded in derivation of a function for transforming coordinates of a feature point in the second image into coordinates of a corresponding feature point in the first image, and the unselected pair is used in evaluation of the function using the RANSAC method, the selected pair and the unselected pair being included in the plurality of pairs.