DeSaltPepper


Author V. C. Mohan
Last modified Date Aug 2014

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. DeSaltPepper 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. Also a tolerance factor exists, but the default value of 0 may be used generally. The tolerance decreases the sensitivity. While -ve numbers can be used but it may distort image.

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 RGB32, RGB24, YUY2 and Planar (YV12 only for 2.5 version) formats may be input. In case of YUY2 and Planar formats option to process or not of U and V values is provided


Details of parameters
Description Name Type Limits Default
Input clip clip none
option of process opt string "salt", "pepper", "both" "both"
tolerance tol integer -5 to 5 0
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 = DeSaltPepper(img, opt = "both",UV = true)
ds1 = DeSaltPepper(img, opt = "salt",UV = false, avg = false)
ds2 = DeSaltPepper(ds1, opt = "pepper",UV = true)

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

To my index page To Avisynth