A non-transitory computer-readable storage medium storing a program that causes a computer to execute an image processing method comprising the steps of:
- acquiring (i) a parallax image generated based on a signal from one of a plurality of photoelectric converters that receive light beams passing through partial pupil regions of an imaging optical system different from each other, and (ii) a captured image generated by combining a plurality of signals from the plurality of photoelectric converters;
- determining whether the parallax image contains a defect;
- calculating a correction value by using the pixel values of the captured image corresponding to the defect determined by the determining;
- correcting one or more pixel values of the parallax image with the corresponding correction value;
- and
- storing the parallax image corrected by correcting in a storage medium.