An image processing apparatus, comprising: a generation means configured to acquire a reference image, acquire an inspection target image which is obtained by image-taking an object, extract a work inspection image from the inspection target image based on a predetermined work image size, extract a plurality of work candidate images (304a-304h) from the reference image, and generate an aligned image by arranging the plurality of work candidate images (304a-304h) around the work inspection image, abutted to one another; subjecting means configured to subject the aligned image to similar region extraction processing to express a similarity between images from which the aligned image is generated; determination means configured to select a work candidate image from among the plurality of work candidate images (304a-304h) that is most similar to the work inspection image and determine the selected work candidate image as a work reference image, based on the aligned image after being subjected to the similar region extraction processing; and comparison means to compare (S111-S118) the work inspection image with the work reference image, wherein the similar region extraction processing subjects each of a plurality of division regions obtained by dividing the aligned image based on predetermined division size and phase of dividing position in the aligned image, to averaging processing, and then adds the results of the averaging processing that are obtained by varying at least one of the division size and phase. a generation means configured to acquire a reference image, acquire an inspection target image which is obtained by image-taking an object, extract a work inspection image from the inspection target image based on a predetermined work image size, extract a plurality of work candidate images (304a-304h) from the reference image, and generate an aligned image by arranging the plurality of work candidate images (304a-304h) around the work inspection image, abutted to one another; acquire a reference image, acquire an inspection target image which is obtained by image-taking an object, extract a work inspection image from the inspection target image based on a predetermined work image size, extract a plurality of work candidate images (304a-304h) from the reference image, and generate an aligned image by arranging the plurality of work candidate images (304a-304h) around the work inspection image, abutted to one another; subjecting means configured to subject the aligned image to similar region extraction processing to express a similarity between images from which the aligned image is generated; determination means configured to select a work candidate image from among the plurality of work candidate images (304a-304h) that is most similar to the work inspection image and determine the selected work candidate image as a work reference image, based on the aligned image after being subjected to the similar region extraction processing; and comparison means to compare (S111-S118) the work inspection image with the work reference image, wherein the similar region extraction processing subjects each of a plurality of division regions obtained by dividing the aligned image based on predetermined division size and phase of dividing position in the aligned image, to averaging processing, and then adds the results of the averaging processing that are obtained by varying at least one of the division size and phase.