The detection of moving objects in a video sequence is the first step in an automatic video surveillance system. This work proposes an enhancement of a codebook-based algorithm for moving objects extraction. The proposed algorithm used a perceptual-based approach to optimize foreground information extraction complexity by using a modified codebook algorithm. The purpose of the adaptive strategy is to reduce the computational complexity of the foreground detection algorithm while maintaining its global accuracy. In this algorithm, we use a superpixels segmentation approach to model the spatial dependencies between pixels. The processing of the superpixels is controlled to focus it on the superpixels that are near to the possible location of foreground objects. The performance of the proposed algorithm is evaluated and compared to other algorithms of the state of the art using a public dataset that proposes sequences with a dynamic background. Experimental results prove that the proposed algorithm obtained the best the frame processing rate during the foreground detection.