1. An image processing apparatus, comprising: an input-closed-curve-image obtaining unit obtaining an image including a closed curve input so as to enclose an object included in an input image; a distance-image generation unit generating a distance image having pixel values set for individual pixels so as to correspond to distances from the input closed curve in accordance with a shape of the input closed curve; an energy calculation unit calculating an input-image energy of the input image which includes a distance energy which is changed in accordance with the distances of the individual pixels or a likelihood energy which is changed in accordance with likelihoods of the individual pixels obtained on the basis of a color distribution model of a region corresponding to the object and a color distribution model of a region other than the object region in the distance image and a color energy which is changed in accordance with color differences between adjacent pixels in the distance image; and a mask-image generation unit generating a mask image by performing calculation so that the input-image energy is minimized and assigning, in accordance with the minimized input-image energy, an attribute representing the object region of the input image or an attribute representing the region other than the object region.