1. An image processing apparatus, comprising: an image obtaining section that obtains a first image and a second image which are obtained by imaging the same subject at different timings; an image deformation amount estimating section that estimates an amount of deformation of the first image by deforming the first image and evaluating the degree of similarity between the deformed first image and the second image using an evaluation function that evaluates the correlative properties between the distribution of pixel values within the deformed first image and the distribution of pixel values within the second image corresponding thereto; and an image generating section that generates an image, which is the first image deformed based on the estimated amount of deformation; the evaluation function evaluating the degree of similarity between the deformed first image and the second image, based on degrees of similarities of divided images that represent degrees of similarities among the distributions of pixel values of each pair of divided first images and divided second images, which respectively are a plurality of images that the deformed first image is divided into according to predetermined dividing conditions and a plurality of images that the second image is divided into such that they correspond to the divided first images; and the dividing conditions dividing the deformed first image into a plurality of divided first images based on a predetermined first spatial parameter, and dividing the second image into a plurality of divided second images that correspond to the divided first images based on a second spatial parameter corresponding to the first spatial parameter.