A program causing processing to be executed on a computer that controls an image processing apparatus, the image processing apparatus including
- 3-value image generating means for generating a 3-value image made up of first through third values from a 2-value image, wherein the 2-value image is made up of a first value indicating, on a per-pixel basis, a foreground image region in an input image, as well as a second value similarly indicating a background image region, and wherein the third value of the 3-value image indicates an unknown region defined differently from both the foreground image region and the background image region such that the unknown region is defined having a predetermined width at the boundary between the foreground image region and the background image region,
- ratio image generating means for generating a ratio image from the input image and the 3-value image, wherein the ratio image is made up of a fourth value that indicates, on a per-pixel basis, the ratio of the first value,
- updating means for updating the 3-value image by defining a predetermined range near a pixel in the 3-value image that corresponds to a pixel in the ratio image whose fourth value is greater than a minimum value and less than a maximum value, and setting all pixels within the defined range to the third value,
- determining means for determining whether or not the 3-value image updated by the updating means is identical or nearly identical to the 3-value image before being updated by the updating means, and
- output means for outputting the updated 3-value image if it is determined that the 3-value image updated by the updating means is identical or nearly identical to the 3-value image before being updated by the updating means, the processing of the program comprising the steps of:
- by means of the 3-value image generating means, generating a 3-value image made up of first through third values from a 2-value image, wherein the 2-value image is made up of a first value indicating, on a per-pixel basis, a foreground image region in an input image, as well as a second value similarly indicating a background image region, and wherein the third value of the 3-value image indicates an unknown region defined differently from both the foreground image region and the background image region such that the unknown region is defined having a predetermined width at the boundary between the foreground image region and the background image region;
- by means of the ratio image generating means, generating a ratio image from the input image and the 3-value image, wherein the ratio image is made up of a fourth value that indicates, on a per-pixel basis, the ratio of the first value;
- by means of the updating means, updating the 3-value image by defining a predetermined range near a pixel in the 3-value image that corresponds to a pixel in the ratio image whose fourth value is greater than a minimum value and less than a maximum value, and setting all pixels within the defined range to the third value;
- by means of the determining means, determining whether or not the 3-value image updated by the updating means is identical or nearly identical to the 3-value image before being updated by the updating means;
- and
- by means of the output means, outputting the updated 3-value image if it is determined that the 3-value image updated by the updating means is identical or nearly identical to the 3-value image before being updated by the updating means.