1. An image processing apparatus comprising: a CPU that is configured to: acquire data of a plurality of images with different focal points; perform first map generation to generate a depth map that represents a distance relationship of a subject, for each of a plurality of acquired images, in an image for each of a predetermined number of pixels; perform second map generation to generate a new depth map by performing predetermined processing on a plurality of the depth maps generated in the first map generation; and composite data of the plurality of images for each pixel according to a ratio of composition for each pixel designated by the new depth map generated in the second map generation, and generate data of an omnifocal image.