1. An image processing apparatus comprising: an image obtaining unit that obtains a first image photographed through an optical system and a second image photographed under optical conditions different from optical conditions in which the first image is photographed; and a defect information generating unit that generates defect information indicating a defect in the first image or the second image by using the first image and the second image, wherein: the first image and the second image are photographed under different optical conditions with regard to at least either of an aperture value and a pupil position.