The detection of LSB steganography is a question of common interest in the research of steganalysis techniques. In this paper, the distribution of the difference between the current pixel value and its neighborhood average pixel value is statistically modeled, and then the variance of this statistical distribution is defined as a measurement of image smoothness. Based on the analysis of the effects on the image smoothness brought by message embedding and LSB plane flipping, a new steganalytic technique capable of reliable detection of spatial LSB steganography is proposed. The algorithm can exactly estimate the amount of hidden messages and detect the existence of hidden messages embedded in the image simultaneously. Experimental results show that the proposed algorithm is effective.