top of page

Comparison of the Gaussian, Median, Sobel, and Bilateral Filters on Salt and Pepper Noise

Yezi Cho

Image processing plays a critical role in enhancing image quality across diverse fields. In particular, the field of medicine requires the best possible visualization using medical imaging techniques in for diagnosis. Despite advancements in medical imaging equipment aimed at improving image quality, the presence of noise unavoidable and remains a challenge. Various types of noise with different causes can impede the interpretation of medical imagery, hindering the accurate detection of object characteristics. The study investigates the performance of the gaussian filter, median filter, sobel filter, and bilateral filter in reducing salt and pepper noise in medical images, such as CT scans, X-rays, and MRIs. The full research can be found here.

To intentionally corrupt the images with salt and pepper noise, apply the denoising filters, and calculate the PSNR value, programming was used along with OpenCV modules and Visual Studio Code. The steps are as below.

a. Obtain a python code for a salt and pepper noise, gaussian filter, median filter, sobel filter, bilateral filter, and PSNR value calculation.

b. Download a medical image.

c. Using Visual Studio Code, convert the image to grayscale.

d. Apply the salt and pepper noise. e. Apply the gaussian filter to (d.).

f. Calculate the PSNR value using the original grayscale image and filtered image (e.)

g. Repeat the steps above for the median filter, sobel filter, and bilateral filter.

1. Salt and pepper noise

Salt and pepper noise is a type of image degradation in which a few pixels are noisy. It is a type of impulse noise in which random pixels are corrupted, resulting in a maximum or minimum gray value. The “salt” refers to white pixels, while the “pepper’ refers to black pixels in the output image. In a 8-bit image, the noise causes pixels to have either value 0 (black) or 255 (white).

Figure 1. Original CT scan

Figure 2. CT scan corrupted with salt and pepper noise

2. Gaussian filter

The gaussian filter is a linear filter used to blur images by convolving the image using the Gaussian function. It outputs a weighted average of each pixel’s neighboring pixels, in which the average is weighted more towards the adjacent pixels to the center pixel. The weight depends only on the Euclidean distance between the pixels.

Figure 3. Corrupted CT scan with gaussian filter

3. Median filter

The median filter is a nonlinear filter that replaces each pixel with the median value of neighboring pixels. Among image corruptions, they are effective in removing salt and pepper noise. A window of size 𝑛 * 𝑛 defines an area around a center pixel, scanning the image. The intensity values of the neighboring pixels in the window determine the median intensity value that becomes the central pixel’s value.

Figure 4. Corrupted CT scan with median filter

4. Sobel filter

The sobel filter, also known as the sobel edge detection filter, convolutes images using the Sobel operator (Sobel-Feldman operator) to highlight edges. It computes the gradient of image intensity, identifying regions with rapid intensity change. As a result, it emphasizes areas of high frequency in the image, which correspond to edges.

Figure 5. Corrupted CT scan with sobel filter

5. Bilateral filter

The bilateral filter is a nonlinear filter that preserves edges while reducing noise. It computes the weighted average of intensity values from neighboring pixels, which depends on the distance between the pixels and intensity of pixels. In contrast to the gaussian filter, for a neighboring pixel to influence the central pixel, it should have a similar intensity value as well.

Figure 6. Corrupted CT scan with bilateral filter

According to compiled data, the median filter was the most effective in reducing salt and pepper noise when observing using the human eye. According to numerical analysis using the PSNR value, the median filter was the most effective with the highest PSNR value.


Manasa Nadipally. (2019). Optimization of Methods for Image-Texture Segmentation Using Ant Colony Optimization. Elsevier EBooks, 21–47.

Semmlow, J. L. (2012). Linear System Analysis. Elsevier EBooks, 317–374.

Paris, S., Kornprobst, P., Tumblin, J., & Durand, F. (2008). Bilateral Filtering: Theory and Applications. Foundations and Trends® in Computer Graphics and Vision, 4(1), 1–75.

Spatial Filters - Gaussian Smoothing. (2024).

Jiang, Y., Wang, H., Cai, Y., & Fu, B. (2022). Salt and Pepper Noise Removal Method Based on the Edge-Adaptive Total Variation Model. Frontiers in Applied Mathematics and Statistics, 8.

Prabhavi Jayanetti. (2020, October 16). Remove Salt and Pepper noise with Median Filtering - Analytics Vidhya - Medium. Medium; Analytics Vidhya. 9db


bottom of page