1. An image processing apparatus for outputting a binary mask image, comprising: trimap image obtaining means for obtaining an input image and a trimap image in which the input image is divided into at least an object region and a background region; pre-dividing means for classifying pixels in the input image on the basis of correlation among the pixels, thereby dividing the input image into a set of small regions; small region adjacent energy calculating means for calculating a small region adjacent energy on the basis of a difference in pixel value of a pixel set at the vicinity of a boundary of a pair of small regions adjacent to each other in the set of small regions; small region likelihood energy calculating means for selecting the object region and the background region in the set of small regions on the basis of the trimap image, constructing a probability model function, obtaining object likelihoods and background likelihoods of the respective small regions using the probability model function, and calculating a small region likelihood energy using the object likelihoods and the background likelihoods; dividing means for dividing the input image into a binary mask image of the foreground and the background using the small region adjacent energy and the small region likelihood energy; and output means for outputting the binary mask image divided by the dividing means, wherein the small region likelihood energy calculating means calculates the object likelihoods and the background likelihoods using the probability model function and using weighted average colors of the respective small regions.