Abstract: A method for separating a first image into two or more portions, such as foreground and background portions, based on the distance of the portions from a camera. The method includes detecting a main image using the camera, such as a CCD video camera and measuring distances from the camera to points in the first image. The method further includes separating the main image into two or more portions, such as background and foreground, based on the measured distance of these portions of the image from the camera. One or more of the separated images can then be combined with a secondary image to produce a composite image. To further refine the separation of the two portions of the main image, the contrast is determined between the two portions of the main image in regions of the main image having sufficiently large distance variations. The combining of the two images is then based on the determined contrast in addition to the distances.