1. An image processing apparatus comprising: dividing means for dividing a target candidate image, which is assigned as a candidate of a target image, into blocks when a photo-mosaic image is generated by dividing the target image into the blocks and replacing each of the blocks with a raw image selected from a plurality of raw images; block classification means for placing each of the blocks in the target candidate image into a class selected from a plurality of classes defined by a characteristic associated with color; comparing means for comparing, for each of the classes, the number of blocks in the target candidate image in a class and the number of raw images in the same class; and selecting means for selecting a target candidate image among a plurality of target candidate images to be assigned as the target image on the basis of comparison results of the target candidate images obtained by the comparing unit.