1. An image processing apparatus comprising: a histogram producing unit that produces a histogram in a color space from an input image; a peak-color extracting unit that extracts a plurality of peak colors having a local maximum frequency of appearance of a color value in the histogram; a representative-color selecting unit that determines whether to unify the extracted plurality of peak colors, based on a feature amount of the extracted plurality of peak colors, and that selects a peak color as a representative color among the extracted plurality of peak colors when the extracted plurality of peak colors are unified, the feature amount comprising a lightness difference among the extracted plurality of peak colors and directions of vectors in the color space, the vectors each showing a shortest distance from one of the extracted plurality of peak colors to a line segment connecting between a reference color and a dark color; and a replacing unit that replaces a color of each pixel in the input image by the representative color.