1. An image processing apparatus comprising: an obtaining unit configured to obtain a first image, a second image, and a third image, the first image being an image captured with focus set at a first distance, the second image being an image captured with focus set at a second distance different from the first distance, the third image being an image captured using an f-number larger than an f-number used in capturing of the first image and the second image; an arranging unit configured to arrange at least a part of the first image and at least a part of the second image at a position based on the third image, wherein the arranging unit shifts the first image and the second image such that a first subject in the first image is superimposed with the first subject in the third image, the first subject being located at the first distance, and such that a second subject in the second image is superimposed with the second subject in the third image, the second subject being located at the second distance; and a combining unit configured to generate a composite image having a deeper depth of field than the first image and the second image by combining the first image and the second image that have been arranged by the arranging unit.