1. An image processing apparatus comprising: defined binary image generating means for generating a defined binary image associated with a level image, which is associated with an input image, the level image having pixel values of individual pixels represented using a first value indicating the level of a pixel value in a foreground image region in the input image, the defined binary image being generated by regarding, in a case where the first value of a pixel in the level image is close to a maximum value or close to a minimum value, the pixel as a defined region pixel located in a defined region and setting the pixel to have a predetermined second value, and by regarding, in a case where the first value of a pixel in the level image is neither close to the maximum value nor the minimum value, the pixel as an undefined region pixel located in an undefined region and setting the pixel to have a predetermined third value; and estimated foreground color image generating means for generating an estimated foreground color image associated with the input image, in which the pixel values of the individual pixels that are regarded as the undefined region pixels and that are set to have the predetermined third value in the defined binary image are set to pixel values of pixels in the input image corresponding to pixels for which distances each obtained from an integrated value of the amounts of change in continuity information are shortest from among the pixels that are regarded as the defined region pixels and that are set to have the predetermined second value.