To overcome the shortcoming that the effect of median filter for impulsive noise was influenced seriously by the window size and noises density, the detachment of the noise detection window and the noise removal window was proposed for corrupted images by pepper and salt noises. Some strategies, such as the large window for noise detection and the small window for noise removal, and the adaptive filter for impulsive noises removal, was employed to improve the performances of the filter. The experiment results showed that the filtering performances were meliorated by a long way. Meanwhile, the filtering performances of the filter were excellent for different noise densities.