A technique for producing a foreground mask from a digital image is based on
receiving
two digital images, wherein a first digital image is derived from a first original
scene image including a foreground photographed against a background having arbitrary
and unknown content matter, and a second digital image is derived from a second
original scene image including substantially the same background but without the
foreground. The second digital image is automatically aligned to the first digital
image without user intervention to generate an aligned digital image including
the background without the foreground. Then, using the first digital image and
the aligned digital image, a foreground mask is produced relating to the spatial
regions in the first digital image pertaining to the foreground, whereby the foreground
mask is subsequently used to generate a composite digital image.