Detecting foreground objects from image sequences has played an important role in many machine vision applications. Background modeling, which is a preliminary processing step for foreground detection, is a challenging task due to the complexity and variety of background regions, unexpected situations, and image artifacts such as noise factors, impairments, etc. In this work, we propose a pixel-based background modeling method that uses nonparametric kernel density estimation and foreground/background classification based on the Bayesian decision rule. To reduce the complexity of the kernel density estimation technique, we estimate the probability density function for the background regions using histograms. Hue, saturation, and value (HSV) color and gradient information is also used to represent the background features. After the background statistics are estimated, we detect the foreground regions by using a background subtracting method based on the Bayesian decision rule, which eliminates the need to select and tune the threshold value for foreground/background region classification. The proposed algorithm is validated using datasets acquired in indoor and outdoor environments with a fixed camera. The proposed algorithm is quantitatively compared with two existing background modeling methods. The experimental results show that the proposed algorithm produces more accurate and stable results.