An image processing apparatus performs image processing based on image data output from an image sensor by receiving reflected light of illumination light reflected from a subject and distance measurement data representing a distance to the subject. The image processing apparatus includes a processor including hardware. The processor is configured to: calculate a depth from the image sensor to the subject based on the distance measurement data calculate a subject distance between the image sensor and the subject based on the image data calculate a difference between the calculated depth and the calculated subject distance and discriminate whether or not an area where a surface of the subject is in a specific state is included in the image data based on the calculated difference.