1. An image processing apparatus comprising: an obtainment unit that obtains a plurality of images obtained by shooting the same subject at different positions, at each of a plurality of timings; a first detection unit that detects a phase difference between the images obtained at the same timing; a second detection unit that detects a phase difference between the images obtained at the same position but at different timings; a generating unit that generates an output image by synthesizing at least some of the images obtained by the obtainment unit so that at least one of the phase differences detected by the first detection unit and the second detection unit is eliminated; and a setting unit that sets a generation condition for the output image generated by the generating unit, wherein the generating unit generates the output image by selecting the images to use in the synthesis and the phase difference to be eliminated based on information of the generation condition for the output image set by the setting unit.