1. An image processing apparatus comprising: a calculating unit configured to calculate at least one of a tangent-line direction and a normal-line direction of an edge around a target pixel in an input image by using a direction and a magnitude of a gradient of pixel values of pixels neighboring the target pixel in the input image; a converting unit configured to convert coordinates of pixels neighboring the target pixel into a rotated coordinate system rotated to coordinate axes in accordance with the tangent-line direction or the normal-line direction of the edge; and a fitting unit configured to obtain a curved surface by using a curved surface model described by a position of pixels on the rotated coordinate system, the curved surface approximating a distribution of local pixel values neighboring the target pixel, and calculate a corrected pixel value of the target pixel from an approximated pixel value of the target pixel on the curved surface.