An image processing apparatus includes: an image acquisition unit configured to acquire an original image containing a periodic pattern including a defective pixel a compensation pattern image acquisition unit configured to acquire a compensation pattern image containing a periodic pattern same as that of the original image a defect location identifying unit configured to identify a position of the defective pixel in the original image and a compensation unit configured to compensate the identified defective pixel of the original image with a pixel on the compensation pattern image that is located in a position corresponding to the position of the defective pixel, to generate a compensated image in which the compensated defective pixel is compensated.