The goal of this project is to build a system for real-time segmentation of foreground characters in a video stream. Segmented foreground characters are used as avatars in a real-time distributed interactive TV application for a remote collaboration type of environment. However, the system can be extended to areas such as video retrieval and classification, object recognition, video surveillance and tracking of moving objects by post-processing the segmented objects.
We are building an interactive TV application where the lecture room is a distributed environment. In this environment, the lecture room has three projectors that are brightly illuminated surfaces on one wall. The camera is on one side of the room and it stays fixed. There is a display table (highly specular surface) in the middle of the room. The lecturer mostly moves in the area between the table and the projector wall. A pan-tilt projector projects the image of the remote lecturer on a white wall opposite the display projectors increasing the sense of immersion and interactivity in this distributed collaboration environment. We would like to segment the lecturer's image out from the live video sequence and transmit it to the remote site in real-time which will be displayed on the wall by the remote pan-tilt projector.
![]() |
![]() |
There have been much work done in video segmentation, the most closely related work to our system is done at USC by A. Francois and G. Medioni on Adaptive Color Background Modeling for Real-Time Segmentation of Video Streams:
They also implemented a system for real-time segmentation of video streams. Their basic algorithms works as follows:
![]() |
These sample images shown in the paper looked quite effective, but also quite deceptive. If one looks carefully, it's noticeable that there are no shadows present in any of the images. Also since we can only see still images it's hard to tell whether the system actually works on video stream where the color and lighting variance is high for many pixels in the image. In which case, it's possible to have large holes in the segmented image that is part of the person that cannot be fixed with simple connected component methods, without introducing chunks of background area into the foreground.

These
samples show the artifacts due to shadows. Since the paper uses
HSV differencing rather than RGB, the system should be able to
deal with hadows, but the measure of hue is not accurate when the
luminance (value) is dark, as is the case in these pictures. The
shadow artifacts shown are not unexpected. Unfortunately in the
case of shadows, most shadowed regions are dark which means the
accuracy of hue reduces, which means more chances of artifacts.
There is no demonstration in the paper on the effectiveness and
usage of the adaptive background model. Also they didnt
talk about what values of learning constant alpha to use to
facilitate convergency in real time video. The still shots do not
show the variance of the background through time.
Since the noise and error induced in color and range measurement are not correlated, the combination of filtering using color and range can produce better results than using either one alone. This was demonstrated in the work by [3]. Because we do not have a stereo camera available, we have not exploited this method.
Adaptive background mixture models for real-time tracking by C. Stauffer and W. Grimson is a more sophisticated algorithm. Stauffer et al. implemented a system for real-time video surveillance and tracking of moving objects. Because the targeted application is to be real-time and long standing, it is important for the system to adapt to a changing background. Here is their basic algorithm:
This algorithm will not be very suitable for the problem presented in this application for the following reasons:
PFinder: Real-Time Tracking of the Human Body is another system that performs real-time tracking and segmentation of humans. It works well for it's purpose, because it uses various models of human motion to facilitate tracking and segmentation. This is an approach worth investigating though the problems we are faced with in this particular setting won't be solved by motion tracking of features alone.
There have been much work in the area of color image segmentation, the most recent work by [1] works very well for images with homogeneous color distribution. This indoor lab setting actually does satisfy this constraint. Unfortunately, the problem 3) precludes us from using a region based technique alone. So how about combining color image segmentation with edge and feature methods? We decided against it because of performance constraints, the fastest region based segmentation we know of takes about 1 second to segment an image of 320x240. Adding edge and feature processing to that would not meet the goal of interactive frame rate.
Optical flow will not work well for problems 1) and 2) and for the fact that the lecturer can spend a long time in one pose with only a small part of the body moving (writing on the board for example). Kalman filtering is most used to track individual features, but won't help with the boundary where most of the potential problem lies. Also, Kalman filtering assumes continuity of motion, which does not always apply to a lecturer who can have sudden changes from jerky motion.
Sample based algorithms are simple to implement and often involves regular operations that are easy to accelerate. They have the advantage of being insensitive to scene complexity (for example occlusion) but are often too sensitive to lighting changes and image noise.
Model based algorithm exploit model and motion continuity, they have the advantage of being more robust against lighting changes and image noise but at the same time their complexity grows with scene complexity. Many model based algorithms have problem dealing with mulitple overlapping objects in motion.
We use an algorithm similar to [2], but with some modifications:

Most video streams are RGB sequences, we chose to convert the frames to HSV sequences because RGB color distance is not well behaved respect to color perception and it is also quite sensitive to lighting changes. HSV separates intensity (value) and chromaticity (hue and saturation). This color model allows us to use color where it is reliably measured and use intensity where its not. Because each component of HSV is not equivalent, the processing is different for each component. The detailed processing follows:
Let Hm , Sm, Vm denote the corresponding components for the mean values of the background pixel. Let Hc, Sc,Vc, note the corresponding components of the current pixel. Let S denote S/V and St denotes the saturation threshold.
Besides standard morphological filters like erosion, dilation, open and close; I have also implemented and used these filters that I found useful for removing noise and patch up holes.

The erosion pass removes patches of pixels whose 8x8 boundary is nearly empty, while the dilation pass fills up regions whose 8x8 boundary is almost full. This makes assumptions about the fact that human body should not have small hole. (not true alwayse). This filter is separable and for the videos I gathered, 8x8 seems to work best.

The right figure above shows which 6 pixels are connected to A. A simple scanning label algorithm will label A to the labels of D, B or C but it might not label B and C the same which can result in the situation shown in the right figure. A second equivalent label pass has to be done to remove equivalent label. See [6] for details.
I have implemented the video segmentation system on WindowsNT platform with DirectMedia & Visual C++ installed, I have also made extensive use Intel's Image Processing Library which supports color conversion, convolution etc. The implementation takes advantage of existing filters in DirectShow like support for loading, capturing video, for compression and decompression, etc. To integrate the background eliminator with DirectShow, a transform filter (in the terms of directShow) is implemented. The system performs at interactive framerate. (~15 frames per second)
image.h-
header file for image utilities
image.cpp-
implementation of image utilies
segment.h-
declaration of the segmenter class
segment.cpp-
implementation of background segmenter (eliminator)
nullnull.cpp,
nullnull.def, nullnull.rc
- Visual C++ generated files for subclassing a transform filter
in directShow
nullnull.dsp-
VC++ project file
The implemented video segmentation system works well when:


The system fails when


The following videos demonstrate the effectiveness and problems of the system pretty well.
A video clip with good contrast between foreground and
backgroun and stable lighting conditions. inFeng.avi,
outFeng.avi
A video clip with reasonable contrast between foreground and
background . inJames.avi,
outJames.avi
A video clip with bad contrast between foreground and backgroun
and unstable lighting conditions. inMilton.avi,
outMilton.avi
In this project, I tried to build a real time segmentation system that can be incorporated into a realtime distribute lecture room type application. For that goal, I chose a simple segmentation algorithm. The system works well under certain constraint (for example stable lighting, good contrast and illumination on the foregound character.) It has problems when the lighting is unstable and the contrast is bad. These problems are expected given the algorithm is based on color differencing and the enviroment changes too frequent to enable adaptive modeling. Also lots of tweaking on the parameters are needed to make the segmentation work well on the boundaries. Too much thresholding tend to remove too much of the foregound character, creating big holes that are hard to patch up especially when boundaries are missing; too little thresholding will leave big patches of background in the scene, and when they are connected to the human, they are hard remove using morphological filtering.
After weeks of trial and error I have some thoughts on segmentation. First, one needs to separate the goals of segmentation. Segmentation is useful for object tracking and understanding. To that end, doing an image segmentation pass to get a good estimate on the person's location and general shape info is possible in realtime using background differencing (when the person involved never moves out of the range of camera). Segmentation of human figure can also be used for content creation like video avatars that can be layered into another enviroment for interactive experiences. Content creation requires high quality on the boundary of the segmented image, this is harder to do in realtime. If the entire sequence is available, good segmentation results can be achieved with user assisted tuning. But if the video is captured in realtime, it really requires a fairly constraint enviroment. I think this is not unreasonable. Given the high quality demands of content creation, the cost in content creation have traditionally been quite high. To put some constraints on the enviroment like special lighting to enable more realistic and real time creation of avatars is not so constraining when compaired to the special instrumentation used in traditional content capture like motion capture.
I would like to exploit some methods that might be able to deal with some of the problems I have encountered when building this segmentation system.
[1] D. Comaniciu and P. Meer, "Robust Analysis of Feature Spaces: Color Image Segmentation", Proc. of CVPR, 1997, 750-755.
[2] A. Francois and G. Medioni, "Adaptive Color Background Modeling for Real-Time Segmentation of Video Streams", Proc. of International on Imaging Science, System, and Technology, 1999, pp. 227-232.
[3] G. Gordon and .., "Background estimation and removal based on range and color", Proc of CVPR, 1999, 459-464.
[4] N. Paragios and R. Deriche, "Unifying Boundary and Region Based Information for Geodesic Active Tracking", Proc of CVPR, 1999, 300-305.
[5] C. Stauffer and W. Grimson. "Adaptive background mixture models for real-time tracking", Proc of CVPR, 1999, 333-339
[6] C.Wren, etc, "PFinder:Real-Time Tracking of the Human Body", IEEE Transaction on Pattern Analysis and Machine Intelligence, 1997, pp 780-785
[7] Identifying connected components, a section on CVOnline gives a very good description on how to located connected components in an image.