Various RemoveSpots functions...
Code:
global Width2 = 768
global Height2 = 576
# =============================================================================
#
# DeSpot() function
#
function RemoveSpotsMC3(clip clp, int "Vectors", int "Show")
{
# Constants
#
_thSCD1 = 400
Vectors = Default(Vectors, 3)
Show = Default(Show, 0)
Vectors = (Vectors < 1) ? 1 : (Vectors > 3) ? 3 : Vectors
Show = (Show < 0) ? 0 : (Show > 2) ? 2 : Show
filter = DeFlicker(clp, border=150, percent=70, lmin=5, lmax=240)
super = MSuper(clp, pel=2, sharp=2)
superfi = MSuper(filter, pel=2, sharp=2)
bvec3 = (Vectors == 3) ? MAnalyse(superfi, isb=true, delta=3, blksize=8, overlap=4, truemotion=true)
bvec2 = (Vectors >= 2) ? MAnalyse(superfi, isb=true, delta=2, blksize=8, overlap=4, truemotion=true)
bvec1 = MAnalyse(superfi, isb=true, delta=1, blksize=8, overlap=4, truemotion=true)
fvec1 = MAnalyse(superfi, isb=false, delta=1, blksize=8, overlap=4, truemotion=true)
fvec2 = (Vectors >= 2) ? MAnalyse(superfi, isb=false, delta=2, blksize=8, overlap=4, truemotion=true)
fvec3 = (Vectors == 3) ? MAnalyse(superfi, isb=false, delta=3, blksize=8, overlap=4, truemotion=true)
backw3 = (Vectors == 3) ? MFlow(clp, super, bvec3, thSCD1=_thSCD1) : NullClip(clp)
backw2 = (Vectors >= 2) ? MFlow(clp, super, bvec2, thSCD1=_thSCD1) : NullClip(clp)
backw1 = MFlow(clp, super, bvec1, thSCD1=_thSCD1)
forw1 = MFlow(clp, super, fvec1, thSCD1=_thSCD1)
forw2 = (Vectors >= 2) ? MFlow(clp, super, fvec2, thSCD1=_thSCD1) : NullClip(clp)
forw3 = (Vectors == 3) ? MFlow(clp, super, fvec3, thSCD1=_thSCD1) : NullClip(clp)
# clpdeg = (Vectors <= 2) ? MDegrain2(clp, superfi, bvec1, fvec1, bvec2, fvec2, plane=4, thsad=400) : \
# MDegrain3(clp, superfi, bvec1, fvec1, bvec2, fvec2, bvec3, fvec3, plane=4, thsad=400)
clpdeg = clp
clp = (Vectors == 1) ? Interleave(backw1, clpdeg, forw1) : \
(Vectors == 2) ? Interleave(backw2, backw1, clpdeg, forw1, forw2) : \
Interleave(backw3, backw2, backw1, clpdeg, forw1, forw2, forw3)
clp = clp.Deflicker(percent=99, lag=5, scene=15, info=false)
# ==== большие черные пятна ====
clp = clp.DeSpot(mthres=8, mwidth=7, mheight=5, merode=33, interlaced=false, median=false, p1=15, p2=8, \
pwidth=50, pheight=50, ranked=true, sign=1, maxpts=0, p1percent=10, dilate=1, fitluma=true, \
blur=1, tsmooth=0, show=Show, mark_v=255, motpn=false, seg=2, color=true, mscene=40, minpts=0)
# ==== большие белые пятна ====
clp = clp.DeSpot(p1=10, mthres=8, p2=6, mwidth=7, mheight=5, merode=33, interlaced=false, median=false, \
pwidth=100, pheight=100, ranked=true, sign=-1, maxpts=0, p1percent=10, dilate=1, fitluma=true, \
blur=1, tsmooth=0, show=Show, mark_v=255, motpn=false, seg=0, color=true, mscene=40, minpts=0)
# ==== маленькие точки и пыль ====
clp = clp.DeSpot(mthres=12, mwidth=7, mheight=5, merode=33, interlaced=false, median=false, p1=15, p2=8, \
pwidth=6, pheight=5, ranked=true, sign=0, maxpts=0, p1percent=10, dilate=1, fitluma=true, \
blur=1, tsmooth=2, show=Show, mark_v=255, motpn=false, seg=1, color=true, mscene=40, minpts=0)
clp = clp.DeSpot(mthres=8, mwidth=7, mheight=5, merode=25, interlaced=false, median=false, p1=10, p2=6, \
pwidth=720, pheight=576, ranked=true, sign=2, maxpts=0, p1percent=2, dilate=1, fitluma=true, \
blur=4, tsmooth=4, show=Show, mark_v=255, motpn=false, seg=1, color=true, mscene=40, minpts=0)
# ==== Маленькие компактные пятна ====
clp = clp.DeSpot(mthres=12, mwidth=7, mheight=5, merode=25, interlaced=false, median=false, p1=15, p2=8, \
pwidth=10, pheight=10, ranked=true, sign=-1, maxpts=0, p1percent=2, dilate=1, fitluma=true, \
blur=4, tsmooth=4, show=Show, mark_v=255, motpn=false, seg=2, color=true, mscene=40, minpts=0)
# ==== линии, входящие в контакт с движением, избегите области движения ====
clp = clp.DeSpot(mthres=13, mwidth=7, mheight=5, merode=16, interlaced=false, median=false, p1=15, p2=13, \
pwidth=140, pheight=100, ranked=true, sign=-1, maxpts=0, p1percent=10, dilate=1, fitluma=true, \
blur=1, tsmooth=0, show=Show, mark_v=255, motpn=false, seg=1, color=true, mscene=40, minpts=0)
# ====================================
clp = clp.DeSpot(p1=20, p2=4, pwidth=200, pheight=150, mthres=22, merode=33, sign=2, show=Show, seg=0, color=false, \
motpn=true, fitluma=true, mark_v=255)
clp = clp.DeSpot(p1=20, p2=12, pwidth=768, pheight=576, mthres=80, merode=33, sign=0, show=Show, seg=0, color=true, \
motpn=true, mark_v=255)
clp = clp.DeSpot(p1=12, p2=22, pwidth=100, pheight=100, mthres=22, merode=25, p1percent=10, sign=0, show=Show, seg=1, \
color=true, motpn=true, mark_v=255)
clp = clp.DeSpot(p1=15, p2=1, pwidth=40, pheight=40, mthres=4, merode=25, p1percent=10, sign=0, show=Show, seg=1, \
color=true, motpn=true, mark_v=255)
clp = clp.DeSpot(p1=35, p2=11, pwidth=250, pheight=250, mthres=23, merode=40, p1percent=1, sign=1, show=Show, seg=2,\
color=true, motpn=false, minpts=6, dilate=1, mscene=100, fitluma=true, blur=1, mark_v=255)
clp = clp.DeSpot(p1=22, p2=5, pwidth=100, pheight=140, mthres=11, merode=58, p1percent=25, sign=1, show=Show, seg=1, \
color=true, motpn=false, minpts=6, maxpts=1200, mwidth=7, mheight=5, dilate=2, mscene=90, fitluma=true, \
blur=2, ranked=true, interlaced=false, mark_v=255)
clp = clp.DeSpot(p1=30, p2=22, pwidth=400, pheight=300, mthres=20, merode=33, p1percent=10, sign=1, show=Show, seg=2, \
color=true, motpn=true, mark_v=255)
clp = clp.DeSpot(sign=2, pwidth=Width2, pheight=Height2, p1=10, p2=6, mthres=8, tsmooth=4, seg=2, blur=4, p1percent=2, \
show=Show, mark_v=255)
clp = clp.DeSpot(p1=30, p2=15, pwidth=Width2, pheight=Height2, mthres=20, motpn=true, dilate=1, seg=1, show=Show, mark_v=255)
clp = clp.DeSpot(p1=30, p2=10, mthres=45, pwidth=Width2, pheight=Height2, minpts=10, dilate=0, ranked=true, \
p1percent=5, mscene=98, merode=35, mwidth=20, mheight=10, sign=2, show=Show, seg=0, color=true, \
motpn=true, fitluma=true, blur=1, mark_v=255)
clp = clp.DeSpot(p1=25, p2=14, mthres=25, pwidth=Width2, pheight=Height2, minpts=3, dilate=3, p1percent=5, \
mscene=98, merode=35, sign=-2, show=Show, seg=2, color=true, motpn=true, fitluma=true, blur=1, mark_v=255)
clp = clp.Despot(p1=28, p2=8, mthres=45, pwidth=850, pheight=850, minpts=10, dilate=0, ranked=true, p1percent=5, mscene=98, \
merode=35, mwidth=20, mheight=10, sign=2, show=Show, seg=0, color=true, motpn=true, fitluma=true, \
blur=1, mark_v=255)
clp = clp.Despot(p1=25, p2=14, mthres=25, pwidth=555, pheight=555, minpts=3, dilate=3, p1percent=5, mscene=98, \
merode=35, sign=-2, show=Show, seg=2, color=true, motpn=true, fitluma=true, blur=1, mark_v=255)
# big black spots
# clp = clp.DeSpot(sign=1, pwidth=45, pheight=45, p1=15, p2=8, mthres=8, color=true, show=Show, mark_v=255)
# thin white lines
# clp = clp.DeSpot(sign=-1, pwidth=140, pheight=100, p1=8, p2=1, mthres=5, show=Show, mark_v=255)
# thick hair lines (avoid real hair)
# clp = clp.DeSpot(sign=-1, pwidth=140, pheight=100, p1=15, p2=13, mthres=13, merode=24, show=Show, mark_v=255)
# lines contacting motion, avoid motion areas
# clp = clp.DeSpot(sign=-1, pwidth=140, pheight=100, p1=15, p2=13, mthres=13, merode=16, seg=1, show=Show, mark_v=255)
# small dots and dust
# clp = clp.DeSpot(pwidth=6, pheight=5, p1=15, p2=8, mthres=12, tsmooth=2, show=Show, mark_v=255)
# Long horizontal scratches
# clp = clp.DeSpot(sign=-1, pwidth=100, pheight=2, p1=15, p2=8, mthres=12, color=true, show=Show, mark_v=255)
# Small compact spots
# clp = clp.DeSpot(sign=-1, pwidth=10, pheight=10, p1=15, p2=8, mthres=12, color=true, show=Show, mark_v=255)
clp = (Vectors == 1) ? SelectEvery(clp, 3, 1) : \
(Vectors == 2) ? SelectEvery(clp, 5, 2) : \
SelectEvery(clp, 7, 3)
return clp
}