1. An image processing apparatus, comprising: a characteristic quantity calculation unit that calculates a characteristic quantity for each pixel of image data from the image data; a tightness determination unit that determines tightness indicating a degree of dispersion of pixels in image data for tightness determination by extracting the pixels having a same characteristic quantity by using the characteristic quantity and generating the image data for tightness determination composed of the pixels having the same characteristic quantity to determine whether each pixel of an image is one of a background and an object entering the image; and a pixel set calculation unit that calculates a set of the pixels of the object entering the image from the pixels in the image data for tightness determination in accordance with a determination of the tightness, wherein the tightness determination unit calculates, for the whole image, the tightness throughout an image of the pixels in the whole image data for tightness determination and, for each pixel, local tightness of the pixels in the image data for tightness determination, compares the tightness throughout the image and the local tightness to determine whether the pixels in the image data for tightness determination are distributed throughout the image data or crowded in a portion of the image data, and if the pixels in the image data for tightness determination are determined to be crowded only in the portion of the image data, the pixel set calculation unit calculates a set of the pixels in the image data for tightness determination.