In many computer vision applications, segmenting and extraction of moving objects in video sequences is an essential task. Background subtraction, by which each input image is subtracted from the reference image, has often been used for this purpose. In this paper, we offer a novel background-subtraction technique for real-time dynamic background generation using color images that are taken from a static camera. The new algorithm, which is based on ‘temporal median filter with exponentially weighted moving average (EWMA) filtering’, is presented that effectively implements a temporal mode operation. The proposed method has the advantage that the parameters of the algorithm are computed automatically. In addition, the new method could start its operation for a sequence of images in which moving objects are included. The efficiency and robustness of the new algorithm is confirmed by the results obtained on a number of outdoor image sequences.