1. An image processing apparatus comprising: an image obtaining unit that obtains an image captured with an image sensor; and a defect information generating unit that generates defect information indicating a defect within the image having been obtained, based upon a value at a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel, wherein: the image sensor captures an image through an optical system; and the defect information is information on a projected image of a defect within an optical path, which manifests in the image.