Salt and Pepper Noise
Definition
The noise that appears as small dots in an image in white or black is called salt-and-pepper noise.
Example
For example, the occurrence of salt-and-pepper noise in the image above means that small dots are scattered throughout the image, as shown below.
Description
Unlike the Gaussian noise, which typically makes the image look blurry, salt-and-pepper noise occurs when extreme values of either $0$ or $1$ are assigned regardless of the surrounding pixels. Since these are much brighter or darker than the nearby pixels, they can easily be removed using a median filter, which takes the median value among the nearby pixels. However, without such processing, they can act as outliers and cause problems in various processing steps.
The name “salt-and-pepper noise” comes intuitively from the appearance of white salt and black pepper sprinkled on a black-and-white image. Numerically, it also includes extreme vectors in color images, such as red dots, blue dots, and green dots.
Code
The following is code in Julia for generating salt-and-pepper noise in an image.
using Images
img = Gray.(load("theblack.jpg"))
pepper = rand(size(img)...) .> 0.001
salt = rand(size(img)...) .< 0.0001
img = img .* pepper
img = img .+ 255salt
save("theblack_noisy.jpg", img)