Salt-and-pepper noise is a form of noise sometimes seen on images. It is also known as impulse noise. This noise can be caused by sharp and sudden disturbances in the image signal. It presents itself as sparsely occurring white and black pixels. An effective noise reduction method for this type of noise is a median filter or a morphological filter.
In this article, we will learn how to remove Salt-Pepper Noise from the image simply using C++ (without using any external image processing library like OpenCV).
- Store the pixel values of input image in an array.
- For each pixel value if it contains 0(black) or 255(white) then compute the average value of its neighbor pixel values, else that pixel value is stored in another array.
- Pixel values of the new array are used for output file.
Below is the simple C++ implementation of Salt-Pepper Noise removal :