1. An image processing apparatus comprising: a processor configured to execute a plurality of tasks, including: an unnecessary component determining task that determines unnecessary component information of a parallax image based on difference information relating to a plurality of parallax images obtained from an optical system, the unnecessary component information corresponding to light reflected inside the optical system; a reduction task that performs reduction processing on: at least one of the parallax image or the difference information before the unnecessary component information is determined by the unnecessary component determining task, or the unnecessary component information determined by the unnecessary component determining task; a magnification task that performs magnification processing on the unnecessary component information or on synthesized unnecessary component information obtained by synthesizing the unnecessary component information of each of the plurality of parallax images; and an unnecessary component reducing task that reduces an unnecessary component by subtracting magnified unnecessary component information obtained by the magnification task, from the parallax image or by subtracting magnified synthesized unnecessary component information obtained by the magnification task, from a synthesized image obtained by synthesizing the plurality of parallax images.