# SaltPepper

Author V. C. Mohan
Dec 2016

Many images have impulse noise. If the impulse is positive it is known as Salt, and if -ve is known as Pepper. These are of one pixel dimension. Removing such noise aids many other types of processing. There are many approaches to eliminate this type of noise. The function SaltPepper uses morphology technique to identify such noise and replace those pixels by average or minimum or maximum whichever is appropriate of the surrounding pixels.

Option to elimiate Salt only or Pepper only or both types is provided.

Once the salt or pepper is identified it is replaced by average value of nearest 8 pixels. If avg is selected as false then in case of salt noise the highest value of neighbourhood and for pepper the lowest value of neighbourhood pixels are used as replacement values.

Feedback loops can vary from 0 to 10. This works only if avg is true. Feedback times image is repeatedly processed usng previous output as input. Practically beyond a value of 5 no significant change occurs. As averaging is involved some blurring occurs.

All avisynth+ supported color space RGB, YUY2 and Planar formats with 8, 16 or 32 bit depth may be input. In case of YUY2 and Planar formats option to process or not of U and V values is provided. This function is thread safe : MT_NICE_FILTER

Details of parameters
Description | Name | Type | Limits | Default
Input clip |  | clip |  | none
option of process | opt | string | "salt", "pepper", "both" | "both"
UV processing required? | uv | boolean | true for u, v process, false for not processing u, v | true
is average is replacement value? | avg | boolean | true for average, false for max value of neighbourhood for salt and minimum value for pepper | true
number of feed back loops in processing to be used. applicable only if avg is true. | feedback | integer | 0 to 10 | 0

#Usage examples:-

    ds = SaltPepper(img, opt = "both",UV = true)
    ds1 = SaltPepper(img, opt = "salt",UV = false, avg = false)
    ds2 = SaltPepper(ds1, opt = "pepper",UV = true)

The image below input is on left and on right output with script
SaltPepper(img, opt = "both",UV = true, tol = 0, avg = true, feedback = 3 )

To my index page | down loadmodPlus plugin | To Avisynth