Since the medical image is usually corrupted by noise, the filter method is applied to remove the noise and improve the image quality. In this paper, a modified adaptive median filter method is proposed for filtering the medical images. When identifying noises, by selecting the maximum and the minimum gray values in the image as a criterion of judging the noise pixels, the probability that a nonnoise pixel is misjudged to be a noisy one is reduced, and the processing time for finding the maximum and minimum gray values in each local window is drastically decreased as well. When filtering the image, according to the noise granularity function (NGF) in a 3×3 window, the filtering window size is adaptively adjusted, then the median filter is used to eliminate the current noise-marked pixel in the median image (MI) generated by the adaptive median filter, and at the same time the noise mark is cancelled. The proposed method may both effectively remove the noises, and preserve image detail information well. The experimental results reveal that the proposed method is particularly effective in filtering the impulse noises, also called salt-and-pepper noises superimposed on images, including computed tomography (CT) and magnetic resonance (MR) images.