Background subtraction is a typical method for moving objects detection. The Gaussian mixture model is one of widely used method to model the background. However, in challenge environments, quick lighting changes, noises and shake of background can influence the detection of moving objects significantly. To solve this problem, an improved Gaussian Mixture Model is proposed in this paper. In the proposed algorithm, Objects are divided into three categories, foreground, background and middle-ground. The proposed algorithm is a segmented process. Moving objects including foreground and middle-ground are extracted firstly; then foreground is segmented from middle-ground. In this way almost middle-ground are filtered, so we can obtain a clear foreground objects. Experimental results show that the proposed algorithm can detect moving objects much more precisely, and it is robust to lighting changes and shadows.