A new switching-based trimmed median filter to remove high-density salt-and-pepper noise in digital images is proposed. Initially, a 3×3 sliding window is applied on each pixel in the noisy image. The minimum- and maximum-intensity values are trimmed, and the noisy pixels are detected based on the predefined threshold value. In the filtering stage, the noisy pixels are replaced by median value of uncorrupted pixels in the trimmed array. At very high noise density, if all the pixels in the sliding window are corrupted, then the proposed algorithm replaces noisy pixels by the midpoint of recently processed pixels. The experimental results for various test images show that the performance of the proposed algorithm is superior to the existing algorithms, namely SMF, WMF, CWMF, AMF, DBA, and MDBUTMF in terms of visual quality and edge preservation, even at noise levels as high as 95%.