The image processing apparatus is provided with a scanner unit that reads
a document and generates image data; an edge vicinity pixel detection
unit that detects pixels in the vicinity of the edge of the document
based on luminance values of the image data generated by the scanner
unit; a histogram creation unit that creates a histogram using the
luminance values of pixels in a region of the document within a
predetermined distance from the pixels in the vicinity of the edge; and a
judgment unit that judges whether or not it is possible to separate a
document region from a document-external region based on the created
histogram.