1. An image processing apparatus for extracting, in accordance with binary image data of a document image, a ruled-line image contained in the document image, the image processing apparatus comprising: a pixel value determination section for determining whether a target pixel of the binary image data is a black pixel or a white pixel; a counting section for counting the number of black pixels connected one after another upstream in a main scanning direction with respect to the target pixel of the binary image data; and a ruled-line image data generation section for, when the target pixel of the binary image data is a black pixel and when a value counted for the target pixel is not less than a main-scanning run determination threshold value that has been set in advance, generating ruled-line image data by correcting, to pixel values corresponding to black pixels, pixel values of a predetermined number of pixels connected to the target pixel upstream in the main scanning direction.