In order to improve the quality of underground images acquisition, according to the advantages and disadvantages of the current median filter algorithm, a new denoising algorithm is proposed which eliminates salt and pepper noise from underground images that are corrupted by salt and pepper noise. The new algorithm first adjusts noise points and non-noise points in image, then determines the size of filtering window adaptively on the basis of the number of noise points in window, and gives corresponding wei...