Aiming at the high wrong-check rate of extremum median filtering in denoising image, an improved image filtering algorithm for the salt and pepper noise is proposed. The algorithm is composed of noise detection and noise filtering. The proposed noise detection method has low wrong-check rate and error-check rate. A multi-window filtering method is then used to revise the gray value of pixels that are labeled as noise. The proposed method is proved to be superior to the traditional median filter and some improved method for different noise image. The PSNR is increased about 16 dB when the noise rate achieves 70%.