SGradation
From Avisynth wiki
#
# SGradation() is a "2nd order gamma" function.
#
# While overall luma and contrast, i.e. levels 0, 128, 255, are not affected,
# SGradation expands or compresses the luma histogram outwards from he center
# (with gamma > 1.0) or towards the center (with gamma < 1.0).
#
# SGradation() allows to soften the visual contrast of images with too much
# contrast. But rather than just reducing all the contrast, SGradation()
# leaves black, medium lightness and white untouched, and just reduces the
# lightness of very light, respectively increases the lightness of dark areas.
# This is useful after recapturing movies if the camera could not cover the
# projection contrast.
#
# On the other hand, the effective contrast of dim pictures can be expanded,
# yet conserving the details in dark and light areas, i.e. not saturating
# and cutting black and white areas, but leaving a soft gradient.
#
#
# Parameters
#
# clip clp
# must be given and is the modified clip.
#
# float gamma
# similar to the well known gamma. Values below 1.0 reduce contrast.
#
# int median
# the luma center point - default 128.
#
# float darkgamma, lightgamma
# allow separate gamma values for the dark/light part of the image.
#
# bool pclevels
# when true, assumes and returns "PC" luma levels.
# (see ColorYUV doc for explanation)
#
#
# output luma with gamma < 1.0
# ^
# 255+ +
# | +
# | +
# | +
# | +
# | +
# | +
# 128+ +++
# | +
# | +
# | +
# | +
# |+
# |+
# 0+-------------+-------------+> input luma
# 0 128 255
#
#
# 04/16/2007 martin53
#
function SGradation(clip clp, val "gamma") {
g=float(default(gamma,1.0))
gc=clp.GreyScale()#.ColorYUV(levels="TV->PC")
dk=gc.Levels(0,1.0/g,127,0,127)
lt=gc.Levels(235,1.0/g,128,107,0,coring=false)
# dk=gc.Levels(127,g,0,127,0)
# lt=gc.Levels(128,g,235,0,107,coring=false)
r=Overlay(dk,lt,mode="add")
r.MergeChroma(clp)#.ColorYUV(levels="PC->TV")
}
Back to Shared functions.