An image processing apparatus includes a dividing unit, a first extracting unit, a quantizing unit, a generating unit and an image output unit. The dividing unit divides an object image into regions. The first extracting unit extracts image features of the regions generated by the dividing unit. The quantizing unit quantizes the image features extracted by the first extracting unit. The generating unit generates an expected value of an occurrence probability of each topic variable indicating similar images from the image features quantized by the quantizing unit, using a correlation between the image features quantized by the quantizing unit and the topic variables. The image output unit outputs an image of a defective portion in the object image, using the expected values of the occurrence probabilities of the topic variables generated by the generating unit.