1. An image processing apparatus comprising: a defective pixel detector for detecting a defective pixel included in an image sensor including a plurality of pixels; an edge direction detector for detecting, based on a pixel value of a pixel of interest in the image sensor, pixel values of first pixels adjacent to the pixel of interest, and the detection result by the defective pixel detector, a luminance gradient direction of second pixels adjacent to the pixel of interest; and a corrector for correcting the pixel value of the pixel of interest based on the detection result by the edge direction detector, wherein the edge direction detector uses different calculations to detect the luminance gradient direction depending on whether the defective pixel detected by the defective pixel detector is included in the first pixels adjacent to the pixel of interest.