Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 4th November 2014, 21:10   #161  |  Link
papcom
Registered User
 
Join Date: Feb 2002
Location: Southwest Germany
Posts: 169
Quote:
Originally Posted by johnmeyer View Post
Yes much better. I never found a single instance where I got better results with DeSpot.

I would recommend you use the motion-compensated version of RemoveDirt. Search on my name and RemoveDirtMC to see how to use it.
thank You again johnmeyer, I am constantly learning. I tried your despot-samplescript and the results look pretty good.

There is unfortunately an issue with the interlaced video (function MDegrain2i2). It shows some strange doubled lines sometimes. Do You have a hint how I can eliminate that?

I would like to add the following code to the script in order to correct levels and color, but I was not successful. Where would you put these 2 lines in Your despot- script?

Code:
SmoothTweak(brightness=-1, contrast=1.0, saturation=1.2, hue1=25, hue2=-29, TVrange=True, Lmode=0, limitSTR=100)
AutoAdjust(auto_balance=true)
SmoothLevels(input_low=1, gamma=1.1, input_high=235, output_low=14, output_high=240, chroma=150, limiter=1, lmode=0)
As You suggested I also searched infos about RemoveDirtMC, but I couldnt find the help I looked for, nor I did find the necessary DLLs. I found a script by @nephilis (dated 2011) but I couldnt make it work. Do You have an informative link about the usage of RemoveDirtMC?
__________________
Lenovo Intel i7Quad/WIN8 - Virtual Dub 1.10.4/Avisinth 2.6MT- MacMini I7 QuadCore

Last edited by papcom; 4th November 2014 at 21:17.
papcom is offline   Reply With Quote
Old 4th November 2014, 22:45   #162  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,349
Quote:
As You suggested I also searched infos about RemoveDirtMC, but I couldnt find the help I looked for, nor I did find the necessary DLLs. I found a script by @nephilis (dated 2011) but I couldnt make it work. Do You have an informative link about the usage of RemoveDirtMC?
This should provide you with a starting point:
Code:
function RemoveDirtMC(clip,int "limit", bool "_grey")
{
  _grey=default(_grey, false)
  limit = default(limit,6)

# prefiltered = fft3dfilter(clip,sigma=1,sigma2=2,sigma3=3,sigma4=5,bw=64,bh=64)
  prefiltered = RemoveGrain(clip,2)
  superfilt = MSuper(prefiltered, hpad=32, vpad=32,pel=2)

  super=MSuper(clip, hpad=32, vpad=32,pel=2)

  bvec = MAnalyse(superfilt,isb=true,  blksize=16, overlap=2,delta=1, truemotion=true)
  fvec = MAnalyse(superfilt,isb=false, blksize=16, overlap=2,delta=1, truemotion=true)

# Increase thSAD if moving objects are being removed!!
  bvec_re = Mrecalculate(super,bvec,blksize=8, overlap=0,thSAD=100)
  fvec_re = Mrecalculate(super,fvec,blksize=8, overlap=0,thSAD=100)

  backw = MFlow(clip,super,bvec_re)
  forw  = MFlow(clip,super,fvec_re)

  clp=interleave(forw,clip,backw)
  clp=clp.RemoveDirt(limit,_grey)
  clp=clp.SelectEvery(3,1)
  return clp
}


function RemoveDirt(clip input, int limit, bool _grey)
{
  clensed=input.Clense(grey=_grey, cache=4)
  alt=input.RemoveGrain(2)
  return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=6,cthreshold=8, gmthreshold=40,dist=3,dmode=2,debug=false,noise=limit,noisy=4, grey=_grey)
}

Last edited by johnmeyer; 8th July 2015 at 14:46. Reason: Change order of vectors in Interleave statement
johnmeyer is offline   Reply With Quote
Old 6th November 2014, 17:00   #163  |  Link
papcom
Registered User
 
Join Date: Feb 2002
Location: Southwest Germany
Posts: 169
thanks JMH - I put a videosource but I don't get any "De-Spotting"... probably I am not enough skilled to understand the mechanism of this script. Where is my mistake?
__________________
Lenovo Intel i7Quad/WIN8 - Virtual Dub 1.10.4/Avisinth 2.6MT- MacMini I7 QuadCore
papcom is offline   Reply With Quote
Old 6th November 2014, 17:50   #164  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,389
Quote:
Originally Posted by papcom View Post
thanks JMH - I put a videosource but I don't get any "De-Spotting"... probably I am not enough skilled to understand the mechanism of this script. Where is my mistake?
An example of the syntax used for this variant is

AVISource("video.avi")
RemoveDirtMC(30,false)

Higher numbers will remove more dirt and detail . If you have things like true duplicates in the source, it might not work. You need to get unique frames for any dirt removal filters to work properly
poisondeathray is offline   Reply With Quote
Old 6th November 2014, 19:45   #165  |  Link
papcom
Registered User
 
Join Date: Feb 2002
Location: Southwest Germany
Posts: 169
Quote:
Originally Posted by poisondeathray View Post
An example of the syntax used for this variant is

AVISource("video.avi")
RemoveDirtMC(30,false)

Higher numbers will remove more dirt and detail. If you have things like true duplicates in the source, it might not work. You need to get unique frames for any dirt removal filters to work properly
I understand the basics, but i do not understand it in the context of the script @johnmeyer postet before. I have a picture but I have not dirt removal. So where is my mistake:

Code:
clip=AviSource("C:\intensitytest8mm.avi")
converttoYV12(clip)

function RemoveDirtMC(clip,int limit, bool "_grey")
{
  _grey=default(_grey, false)
  limit = default(limit,6)

#~ prefiltered = fft3dfilter(clip,sigma=1,sigma2=2,sigma3=3,sigma4=5,bw=64,bh=64)
  prefiltered = RemoveGrain(clip,2)
  superfilt = MSuper(prefiltered, hpad=32, vpad=32,pel=2)

  super=MSuper(clip, hpad=32, vpad=32,pel=2)

  bvec = MAnalyse(superfilt,isb=true,  blksize=16, overlap=2,delta=1, truemotion=true)
  fvec = MAnalyse(superfilt,isb=false, blksize=16, overlap=2,delta=1, truemotion=true)

# Increase thSAD if moving objects are being removed!!
  bvec_re = Mrecalculate(super,bvec,blksize=8, overlap=0,thSAD=100)
  fvec_re = Mrecalculate(super,fvec,blksize=8, overlap=0,thSAD=100)

  backw = MFlow(clip,super,bvec_re)
  forw  = MFlow(clip,super,fvec_re)

  clp=interleave(backw,clip,forw)
  clp=clp.RemoveDirt(limit,_grey)
  clp=clp.SelectEvery(3,1)
  return clp
}

function RemoveDirt(clip input, int limit, bool _grey)
{
  clensed=input.Clense(grey=_grey, cache=4)
  alt=input.RemoveGrain(2)
  return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=6,cthreshold=8, gmthreshold=40,dist=3,dmode=2,debug=false,noise=limit,noisy=4, grey=_grey)
}

#~ SmoothLevels(input_low=6, gamma=1.1, input_high=235, output_low=16, output_high=235, chroma=100, limiter=1, lmode=0)
#~ SmoothTweak(brightness=0, contrast=1.0, saturation=1.0, hue1=-1, hue2=0, TVrange=True, Lmode=0, limitSTR=100)
#~ AutoAdjust(auto_balance=true)
__________________
Lenovo Intel i7Quad/WIN8 - Virtual Dub 1.10.4/Avisinth 2.6MT- MacMini I7 QuadCore

Last edited by papcom; 6th November 2014 at 19:48.
papcom is offline   Reply With Quote
Old 6th November 2014, 20:05   #166  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,389
Quote:
Originally Posted by papcom View Post
I understand the basics, but i do not understand it in the context of the script @johnmeyer postet before. I have a picture but I have not dirt removal. So where is my mistake:

Code:
clip=AviSource("C:\intensitytest8mm.avi")
converttoYV12(clip)

function RemoveDirtMC(clip,int limit, bool "_grey")
{
  _grey=default(_grey, false)
  limit = default(limit,6)

#~ prefiltered = fft3dfilter(clip,sigma=1,sigma2=2,sigma3=3,sigma4=5,bw=64,bh=64)
  prefiltered = RemoveGrain(clip,2)
  superfilt = MSuper(prefiltered, hpad=32, vpad=32,pel=2)

  super=MSuper(clip, hpad=32, vpad=32,pel=2)

  bvec = MAnalyse(superfilt,isb=true,  blksize=16, overlap=2,delta=1, truemotion=true)
  fvec = MAnalyse(superfilt,isb=false, blksize=16, overlap=2,delta=1, truemotion=true)

# Increase thSAD if moving objects are being removed!!
  bvec_re = Mrecalculate(super,bvec,blksize=8, overlap=0,thSAD=100)
  fvec_re = Mrecalculate(super,fvec,blksize=8, overlap=0,thSAD=100)

  backw = MFlow(clip,super,bvec_re)
  forw  = MFlow(clip,super,fvec_re)

  clp=interleave(backw,clip,forw)
  clp=clp.RemoveDirt(limit,_grey)
  clp=clp.SelectEvery(3,1)
  return clp
}

function RemoveDirt(clip input, int limit, bool _grey)
{
  clensed=input.Clense(grey=_grey, cache=4)
  alt=input.RemoveGrain(2)
  return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=6,cthreshold=8, gmthreshold=40,dist=3,dmode=2,debug=false,noise=limit,noisy=4, grey=_grey)
}

#~ SmoothLevels(input_low=6, gamma=1.1, input_high=235, output_low=16, output_high=235, chroma=100, limiter=1, lmode=0)
#~ SmoothTweak(brightness=0, contrast=1.0, saturation=1.0, hue1=-1, hue2=0, TVrange=True, Lmode=0, limitSTR=100)
#~ AutoAdjust(auto_balance=true)

The mistake is you haven't called the filter.

Posting the function doesn't "activate" it. You need to explictly call RemoveDirtMC(some settings)

See my previous post
poisondeathray is offline   Reply With Quote
Old 6th November 2014, 21:39   #167  |  Link
papcom
Registered User
 
Join Date: Feb 2002
Location: Southwest Germany
Posts: 169
Quote:
Originally Posted by poisondeathray View Post
The mistake is you haven't called the filter.

Posting the function doesn't "activate" it. You need to explictly call RemoveDirtMC(some settings)

See my previous post
...sorry @poisondeathray, I have no idea what exactely You are meaning.

Can You show me the way with the script I postdt before?
__________________
Lenovo Intel i7Quad/WIN8 - Virtual Dub 1.10.4/Avisinth 2.6MT- MacMini I7 QuadCore
papcom is offline   Reply With Quote
Old 6th November 2014, 21:50   #168  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,389
It's ok

The functions you got from John (or any function for that matter) , don't do anything, until you call them (activate them)

At the bottom, you have SmoothLevels, SmoothTweak, etc... those lines are preceded by a "#" , so those lines are "turned off" because they are commented out


Code:
AviSource("C:\intensitytest8mm.avi")
converttoYV12()
RemoveDirtMC(30,false)





function RemoveDirtMC(clip,int limit, bool "_grey")
{
  _grey=default(_grey, false)
  limit = default(limit,6)

#~ prefiltered = fft3dfilter(clip,sigma=1,sigma2=2,sigma3=3,sigma4=5,bw=64,bh=64)
  prefiltered = RemoveGrain(clip,2)
  superfilt = MSuper(prefiltered, hpad=32, vpad=32,pel=2)

  super=MSuper(clip, hpad=32, vpad=32,pel=2)

  bvec = MAnalyse(superfilt,isb=true,  blksize=16, overlap=2,delta=1, truemotion=true)
  fvec = MAnalyse(superfilt,isb=false, blksize=16, overlap=2,delta=1, truemotion=true)

# Increase thSAD if moving objects are being removed!!
  bvec_re = Mrecalculate(super,bvec,blksize=8, overlap=0,thSAD=100)
  fvec_re = Mrecalculate(super,fvec,blksize=8, overlap=0,thSAD=100)

  backw = MFlow(clip,super,bvec_re)
  forw  = MFlow(clip,super,fvec_re)

  clp=interleave(backw,clip,forw)
  clp=clp.RemoveDirt(limit,_grey)
  clp=clp.SelectEvery(3,1)
  return clp
}

function RemoveDirt(clip input, int limit, bool _grey)
{
  clensed=input.Clense(grey=_grey, cache=4)
  alt=input.RemoveGrain(2)
  return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=6,cthreshold=8, gmthreshold=40,dist=3,dmode=2,debug=false,noise=limit,noisy=4, grey=_grey)
}

#~ SmoothLevels(input_low=6, gamma=1.1, input_high=235, output_low=16, output_high=235, chroma=100, limiter=1, lmode=0)
#~ SmoothTweak(brightness=0, contrast=1.0, saturation=1.0, hue1=-1, hue2=0, TVrange=True, Lmode=0, limitSTR=100)
#~ AutoAdjust(auto_balance=true)
poisondeathray is offline   Reply With Quote
Old 6th November 2014, 22:56   #169  |  Link
papcom
Registered User
 
Join Date: Feb 2002
Location: Southwest Germany
Posts: 169
thank You @poisondeathray - that's very kind. Now it works. Great.
__________________
Lenovo Intel i7Quad/WIN8 - Virtual Dub 1.10.4/Avisinth 2.6MT- MacMini I7 QuadCore
papcom is offline   Reply With Quote
Old 8th November 2014, 12:58   #170  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
Part 1.
.
Code:
#
#
# File: RemoveDirt.avsi
#
# RemoveTempGrain, RemoveDirt and moution compensated RemoveDirt functions
#
# Functions:
#
#   function NullClip(clip clp)
#
#   function RemoveTempGrain(clip clp, int "_mode")
#
#   function RemoveDirt(clip clp, int "limit", bool "_grey")
#   function RemoveDirtMC(clip clp, int "limit", bool "_grey", int "Vectors")
#
#   function RemoveDirt2(clip clp, int "limit", int "rgrain", bool "_grey")
#   function RemoveDirtMC2(clip clp, int "limit", int "rgrain", bool "_grey", int "Vectors")
#
#   function RemoveDirt_HQ(clip clp, int tlimit, int rgrain, bool "_grey")
#   function RemoveDirt_HQMC(clip clp, int "limit", int "rgrain", bool "_grey", int "Vectors")
#
#   function RemoveDirtCareful(clip clp, int "th", bool "show")
#   function RemoveDirtCarefulMC(clip clp, int "th", bool "show", int "Vectors")
#
#   function RemoveDirtS(clip clp, int "limit", bool "_grey")
#   function RemoveDirtSMC(clip clp, int "limit", bool "_grey", int "Vectors")
#   function HQ_FilterS(clip clp, int "Vectors")
#
#





LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEDIRT_20050507\removedirt.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEDIRT_20050507\removedirts.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEGRAIN-1_0\repair.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEGRAIN-1_0\removegrain.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEGRAINT-1_0\repairt.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEGRAINT-1_0\removegraint.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MVTOOLS-V2_5_11_3\mvtools2.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEDIRT_20050507\removedirt.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\FLUXSMOOTH_25_DLL_20040729\fluxsmooth.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\VAGUEDENOISER_25_DLL_20050926\vaguedenoiser.dll")

Import("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\YLEVELS\ylevels.avsi")





function NullClip(clip clp)
{
  return (BlankClip(clp, length=0))
}



# =============================================================================
# 
#
function RemoveTempGrain(clip clp, int "_mode")
{
  _mode = Default(_mode, 17)

  rg    = RemoveGrain(clp, mode=_mode)
  clp   = TemporalRepair(rg, clp)

  return (clp)
}



# =============================================================================
# 
#
function RemoveDirt(clip clp, int "limit", bool "_grey")
{
  _grey     = Default(_grey, false)
  limit     = Default(limit, 16)

  clmode    = 17
  clensed   = Clense(clp, grey=_grey, cache=4)
  sbegin    = ForwardClense(clp, grey=_grey, cache=-1)
  send      = BackwardClense(clp, grey=_grey, cache=-1)
  alt       = Repair(SCSelect(clp, sbegin, send, clensed, debug=true), clp, mode=limit, modeU = _grey ? -1 : limit)
  restore   = Repair(clensed, clp, mode=limit, modeU = _grey ? -1 : limit)
  corrected = RestoreMotionBlocks(clensed, restore, neighbour=clp, alternative=alt, gmthreshold=70, dist=1, \
                                  dmode=2, debug=false, noise=10, noisy=12, grey=_grey)
  clp       = RemoveGrain(corrected, mode=clmode, modeU = _grey ? -1 : clmode)

  return (clp)
}	


# RemoveDirtMC2 by heini011 on 26 February 2006
# Suggested by johnmeyer on 09 June 2010
# Incorporated into Filmrestoration script by videoFred on 08 July 2010
# Fixed (vector direction) by nephilis on 01 August 2010
# Fixed (swapped parameters) by Emulgator to work with recent MVTools 2.5.10.1 on 20 September 2010
#
function RemoveDirtMC(clip clp, int "limit", bool "_grey", int "Vectors")
{
  _grey   = Default(_grey, false)
  limit   = Default(limit, 6)
  Vectors = Default(Vectors, 1)
  Vectors = (Vectors < 1) ? 1 : (Vectors > 3) ? 3 : Vectors
  
  super   = MSuper(clp, pel=2, sharp=2)
  bvec3   = (Vectors == 3) ? MAnalyse(super, isb=true,  delta=3, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  bvec2   = (Vectors >= 2) ? MAnalyse(super, isb=true,  delta=2, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  bvec1   = MAnalyse(super, isb=true,  delta=1, blksize=8, overlap=4, truemotion=true)
  fvec1   = MAnalyse(super, isb=false, delta=1, blksize=8, overlap=4, truemotion=true)
  fvec2   = (Vectors >= 2) ? MAnalyse(super, isb=false, delta=2, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  fvec3   = (Vectors == 3) ? MAnalyse(super, isb=false, delta=3, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  backw3  = (Vectors == 3) ? MFlow(clp, super, bvec3) : NullClip(clp)
  backw2  = (Vectors >= 2) ? MFlow(clp, super, bvec2) : NullClip(clp)
  backw1  = MFlow(clp, super, bvec1)
  forw1   = MFlow(clp, super, fvec1)
  forw2   = (Vectors >= 2) ? MFlow(clp, super, fvec2) : NullClip(clp)
  forw3   = (Vectors == 3) ? MFlow(clp, super, fvec3) : NullClip(clp)

  clp     = (Vectors == 1) ? interleave(backw1, clp, forw1) : \
            (Vectors == 2) ? interleave(backw2, backw1, clp, forw1, forw2) : \
                             interleave(backw3, backw2, backw1, clp, forw1, forw2, forw3)

  clp     = RemoveDirt(clp, limit=limit, _grey=_grey)
         
  clp     = (Vectors == 1) ? SelectEvery(clp, 3, 1) : \
            (Vectors == 2) ? SelectEvery(clp, 5, 2) : \
                             SelectEvery(clp, 7, 3)

  return (clp)
}
__________________
Warm and fuzzy (white and fluffy)
Jenyok is offline   Reply With Quote
Old 8th November 2014, 12:59   #171  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
Part 2 .
.
Code:
# =============================================================================
# 
#
function RemoveDirt2(clip clp, int "limit", int "rgrain", bool "_grey")
{
  _grey   = Default(_grey, false)
  limit   = Default(limit, 6)
  rgrain  = Default(rgrain, 2)

  _dgr1   = 0.35 + rgrain * 0.3
  _dgr2   = 0.45 + rgrain * 0.4
  repmode = 1
  clensed = Clense(clp, grey=_grey, cache=4)
  restore = clp.FluxSmoothST(3 + 3 * rgrain, rgrain)
  restore = Repair(restore, clp, mode=repmode, modeU=(_grey) ? -1 : repmode)
  restore = (rgrain == 0) ? restore.RemoveGrain(1) : \
                            restore.VagueDenoiser(threshold=_dgr1, chromaT=_dgr1, nsteps=7, percent=75).RemoveGrain(1)
  alt     = clp.VagueDenoiser(threshold=_dgr2, chromaT=_dgr2, nsteps=7, percent=100).RemoveGrain(5)
  clp     = RestoreMotionBlocks(clensed, restore, neighbour=clp, alternative=alt,                   \
                                pthreshold=4 + 2 * rgrain, cthreshold=6 + 2 * rgrain, gmthreshold=40, \
                                dist=1, dmode=2, debug=false, noise=limit, noisy=12, grey=_grey)

# Alternative settings
#
#  clp     = RestoreMotionBlocks(clensed, clp, alternative=alt, pthreshold=4, cthreshold=6, gmthreshold=40, dist=1, dmode=2, \
#                                debug=false, noise=limit, noisy=12, grey=_grey, show=true)
#
#  clp     = RestoreMotionBlocks(clensed, clp, alternative=alt, pthreshold=6, cthreshold=8, gmthreshold=40, dist=3, \
#                                tolerance=12, dmode=2, debug=false, noise=limit, noisy=12, grey=_ grey, show=false)

  return (clp)
}


# RemoveDirtMC2 by heini011 on 26 February 2006
# Suggested by johnmeyer on 09 June 2010
# Incorporated into Filmrestoration script by videoFred on 08 July 2010
# Fixed (vector direction) by nephilis on 01 August 2010
# Fixed (swapped parameters) by Emulgator to work with recent MVTools 2.5.10.1 on 20 September 2010
#
function RemoveDirtMC2(clip clp, int "limit", int "rgrain", bool "_grey", int "Vectors")
{
  _grey   = Default(_grey, false)
  limit   = Default(limit, 6)
  rgrain  = Default(rgrain, 2)
  Vectors = Default(Vectors, 1)
  Vectors = (Vectors < 1) ? 1 : (Vectors > 3) ? 3 : Vectors

  super   = MSuper(clp, pel=2, sharp=2)
  bvec3   = (Vectors == 3) ? MAnalyse(super, isb=true,  delta=3, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  bvec2   = (Vectors >= 2) ? MAnalyse(super, isb=true,  delta=2, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  bvec1   = MAnalyse(super, isb=true,  delta=1, blksize=8, overlap=4, truemotion=true)
  fvec1   = MAnalyse(super, isb=false, delta=1, blksize=8, overlap=4, truemotion=true)
  fvec2   = (Vectors >= 2) ? MAnalyse(super, isb=false, delta=2, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  fvec3   = (Vectors == 3) ? MAnalyse(super, isb=false, delta=3, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  backw3  = (Vectors == 3) ? MFlow(clp, super, bvec3) : NullClip(clp)
  backw2  = (Vectors >= 2) ? MFlow(clp, super, bvec2) : NullClip(clp)
  backw1  = MFlow(clp, super, bvec1)
  forw1   = MFlow(clp, super, fvec1)
  forw2   = (Vectors >= 2) ? MFlow(clp, super, fvec2) : NullClip(clp)
  forw3   = (Vectors == 3) ? MFlow(clp, super, fvec3) : NullClip(clp)

  clp     = (Vectors == 1) ? interleave(backw1, clp, forw1) : \
            (Vectors == 2) ? interleave(backw2, backw1, clp, forw1, forw2) : \
                             interleave(backw3, backw2, backw1, clp, forw1, forw2, forw3)

  clp     = RemoveDirt2(clp, limit=limit, rgrain=rgrain, _grey=_grey)

  clp     = (Vectors == 1) ? SelectEvery(clp, 3, 1) : \
            (Vectors == 2) ? SelectEvery(clp, 5, 2) : \
                             SelectEvery(clp, 7, 3)

  return (clp)
}



# =============================================================================
# 
#
function RemoveDirt_HQ(clip clp, int "limit", int "rgrain", bool "_grey")
{
  _grey   = Default(_grey, false)
  limit   = Default(limit, 6)
  rgrain  = Default(rgrain, 2)

  _dgr    = 0.4 + rgrain * 0.25
  clensed = clp.RemoveTempGrain(1).FluxSmoothST(limit, rgrain)
  restore = clp.VagueDenoiser(threshold=_dgr, nsteps=6, chromaT=_dgr, percent=100).RemoveGrain(1)
  alt     = restore
  clp     = RestoreMotionBlocks(clensed, restore, neighbour=clp, alternative=alt, pthreshold=3 + 2 * rgrain, \
                                cthreshold=3 + 2 * rgrain, gmthreshold=40, dist=1, dmode=1, debug=false, \
                                noise=limit + 1, noisy=12, grey=_grey)

  return (clp)
}


function RemoveDirt_HQMC(clip clp, int "limit", int "rgrain", bool "_grey", int "Vectors")
{
  _grey   = Default(_grey, false)
  limit   = Default(limit, 6)
  rgrain  = Default(rgrain, 2)
  Vectors = Default(Vectors, 1)
  Vectors = (Vectors < 1) ? 1 : (Vectors > 3) ? 3 : Vectors

  super   = MSuper(clp, pel=2, sharp=2)
  bvec3   = (Vectors == 3) ? MAnalyse(super, isb=true,  delta=3, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  bvec2   = (Vectors >= 2) ? MAnalyse(super, isb=true,  delta=2, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  bvec1   = MAnalyse(super, isb=true,  delta=1, blksize=8, overlap=4, truemotion=true)
  fvec1   = MAnalyse(super, isb=false, delta=1, blksize=8, overlap=4, truemotion=true)
  fvec2   = (Vectors >= 2) ? MAnalyse(super, isb=false, delta=2, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  fvec3   = (Vectors == 3) ? MAnalyse(super, isb=false, delta=3, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  backw3  = (Vectors == 3) ? MFlow(clp, super, bvec3) : NullClip(clp)
  backw2  = (Vectors >= 2) ? MFlow(clp, super, bvec2) : NullClip(clp)
  backw1  = MFlow(clp, super, bvec1)
  forw1   = MFlow(clp, super, fvec1)
  forw2   = (Vectors >= 2) ? MFlow(clp, super, fvec2) : NullClip(clp)
  forw3   = (Vectors == 3) ? MFlow(clp, super, fvec3) : NullClip(clp)

  clp     = (Vectors == 1) ? interleave(backw1, clp, forw1) : \
            (Vectors == 2) ? interleave(backw2, backw1, clp, forw1, forw2) : \
                             interleave(backw3, backw2, backw1, clp, forw1, forw2, forw3)

  clp     = RemoveDirt_HQ(clp, limit=limit, rgrain=rgrain, _grey=_grey)
  
  clp     = (Vectors == 1) ? SelectEvery(clp, 3, 1) : \
            (Vectors == 2) ? SelectEvery(clp, 5, 2) : \
                             SelectEvery(clp, 7, 3)

  return (clp)
}
__________________
Warm and fuzzy (white and fluffy)
Jenyok is offline   Reply With Quote
Old 8th November 2014, 13:00   #172  |  Link
Jenyok
Warm and fuzzy
 
Join Date: Apr 2010
Location: Moscow, Russia
Posts: 201
Part 3.
.
Code:
# =============================================================================
# 
#
function RemoveDirtCareful(clip clp, int "th", bool "show")
{
	
  th       = Default(th, 16)
  show     = Default(show, false)
  dirtless = clp.RemoveDirt()
#  dirtless = clp.RemoveDirt2()

  maskd    = yv12lutxy(clp, dirtless, yexpr="x y - abs 16 > 255 0 ?", Y=3, U=-128, V=-128)
  maskd    = maskd.expand().reduceby2().reduceby2().expand(Y=3, U=-128, V=-128)
  dirtless = (show == true) ? dirtless.subtitle("removedirt-ed") : dirtless
	
  clp      = Conditionalfilter(maskd, clp, dirtless, "Ydifferencefromprevious()+Ydifferencetonext()", "greaterthan", string(th))
	
#  scriptclip(maskd, "subtitle(string(Ydifferencefromprevious()+Ydifferencetonext()))")

  return (clp)
}


function RemoveDirtCarefulMC(clip clp, int "th", bool "show", int "Vectors")
{
  th      = Default(th, 16)
  show    = Default(show, false)
  Vectors = Default(Vectors, 1)
  Vectors = (Vectors < 1) ? 1 : (Vectors > 3) ? 3 : Vectors

  super   = MSuper(clp, pel=2, sharp=2)
  bvec3   = (Vectors == 3) ? MAnalyse(super, isb=true,  delta=3, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  bvec2   = (Vectors >= 2) ? MAnalyse(super, isb=true,  delta=2, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  bvec1   = MAnalyse(super, isb=true,  delta=1, blksize=8, overlap=4, truemotion=true)
  fvec1   = MAnalyse(super, isb=false, delta=1, blksize=8, overlap=4, truemotion=true)
  fvec2   = (Vectors >= 2) ? MAnalyse(super, isb=false, delta=2, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  fvec3   = (Vectors == 3) ? MAnalyse(super, isb=false, delta=3, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  backw3  = (Vectors == 3) ? MFlow(clp, super, bvec3) : NullClip(clp)
  backw2  = (Vectors >= 2) ? MFlow(clp, super, bvec2) : NullClip(clp)
  backw1  = MFlow(clp, super, bvec1)
  forw1   = MFlow(clp, super, fvec1)
  forw2   = (Vectors >= 2) ? MFlow(clp, super, fvec2) : NullClip(clp)
  forw3   = (Vectors == 3) ? MFlow(clp, super, fvec3) : NullClip(clp)

  clp     = (Vectors == 1) ? interleave(backw1, clp, forw1) : \
            (Vectors == 2) ? interleave(backw2, backw1, clp, forw1, forw2) : \
                             interleave(backw3, backw2, backw1, clp, forw1, forw2, forw3)
  
  clp     = RemoveDirtCareful(clp, th=th, show=show)
  
  clp     = (Vectors == 1) ? SelectEvery(clp, 3, 1) : \
            (Vectors == 2) ? SelectEvery(clp, 5, 2) : \
                             SelectEvery(clp, 7, 3)

  return (clp)
}



# =============================================================================
# 
#
function RemoveDirtS(clip clp, int "limit", bool "_grey")
{
  _grey   = Default(_grey, false)
  limit   = Default(limit, 6)

  clensed = clp.Clense(grey=_grey, cache=4)
  alt     = clp.RemoveGrain(2)
  clp     = RestoreMotionBlocks(clensed, clp, alternative=alt, pthreshold=4, cthreshold=6, gmthreshold=40, \
                                dist=1, dmode=2, debug=false, noise=limit, noisy=16, grey=_grey)

  return (clp)
}

function RemoveDirtSMC(clip clp, int "limit", bool "_grey", int "Vectors")
{
  _grey   = Default(_grey, false)
  limit   = Default(limit, 6)
  Vectors = Default(Vectors, 1)
  Vectors = (Vectors < 1) ? 1 : (Vectors > 3) ? 3 : Vectors

  super   = MSuper(clp, pel=2, sharp=2)
  bvec3   = (Vectors == 3) ? MAnalyse(super, isb=true,  delta=3, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  bvec2   = (Vectors >= 2) ? MAnalyse(super, isb=true,  delta=2, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  bvec1   = MAnalyse(super, isb=true,  delta=1, blksize=8, overlap=4, truemotion=true)
  fvec1   = MAnalyse(super, isb=false, delta=1, blksize=8, overlap=4, truemotion=true)
  fvec2   = (Vectors >= 2) ? MAnalyse(super, isb=false, delta=2, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  fvec3   = (Vectors == 3) ? MAnalyse(super, isb=false, delta=3, blksize=8, overlap=4, truemotion=true) : NullClip(clp)
  backw3  = (Vectors == 3) ? MFlow(clp, super, bvec3) : NullClip(clp)
  backw2  = (Vectors >= 2) ? MFlow(clp, super, bvec2) : NullClip(clp)
  backw1  = MFlow(clp, super, bvec1)
  forw1   = MFlow(clp, super, fvec1)
  forw2   = (Vectors >= 2) ? MFlow(clp, super, fvec2) : NullClip(clp)
  forw3   = (Vectors == 3) ? MFlow(clp, super, fvec3) : NullClip(clp)

  clp     = (Vectors == 1) ? interleave(backw1, clp, forw1) : \
            (Vectors == 2) ? interleave(backw2, backw1, clp, forw1, forw2) : \
                             interleave(backw3, backw2, backw1, clp, forw1, forw2, forw3)
  
  clp     = RemoveDirtS(clp, limit=limit, _grey=_grey)
  dnc     = RemoveTempGrain(clp, 1)

  clp     = (Vectors == 1) ? SelectEvery(clp, 3, 1) : \
            (Vectors == 2) ? SelectEvery(clp, 5, 2) : \
                             SelectEvery(clp, 7, 3)
  dnc     = (Vectors == 1) ? SelectEvery(dnc, 3, 1) : \
            (Vectors == 2) ? SelectEvery(dnc, 5, 2) : \
                             SelectEvery(dnc, 7, 3)
  
  clp     = clp.SeeSaw(dnc, Sstr=0.26, Szp=12, SdampHi=20, bias=40)

  return (clp)
}


function HQ_FilterS(clip clp, int "Vectors")
{
  Vectors = Default(Vectors, 1)
  Vectors = (Vectors < 1) ? 1 : (Vectors > 3) ? 3 : Vectors

  clp = clp.RemoveDirtSMC(limit=6, Vectors=Vectors)
  clp = clp.YlevelsS(0, 1.05, 255, 0, 255)
  clp = clp.LimitedSharpenFaster(Smode=4, strength=18, overshoot=1, wide=false)

  return (clp)
}





##########################################################################################################################
# -------													   	 #
# Usage  : 														 #
# -------		                           			                                                 #
#															 #
# RemoveDirtMC_SE(clip input, bool"GPU", int"radius", int"repmode", int"clmode", bool"TwoPass", int"thSAD", int"thSADC") #
#												   	         	 #
##########################################################################################################################
#
# ----------
# GPU       : -- To choose NLMeansCL or FFT3Dfilter for PreFiltering process.
# ----------     ATI GPU owners should use "GPU=false" 
#	     	      
# ----------
# Radius    : -- Temporal Radius for MDeGrain at second stage DeNoising.
# ----------
#
# ----------
# repmode   : -- Repair mode value in main RemoveDirtSE function.
# ----------     
#
# ----------
# clmode    : -- RemoveGrain mode value in main RemoveDirtSE function.
# ----------
#
# ----------
# Twopass   : -- To make a Temporal Denoising (MDeGrain) after Spatial Denoising (RemoveDirtSE).   
# ----------   
#
# ----------
# thSAD, 
# thSADC    : -- MDeGrain's thSAD and thSADC parameters.
# ---------- 
#
##########################################################################################################################
function RemoveDirtMC_SE(clip input, bool"GPU", int"radius", int"repmode", int"clmode", bool"TwoPass", int"thSAD", int"thSADC")
{
  version = "v1.2"

  GPU     = default(GPU,     true)
  radius  = default(radius,     3)
  repmode = default(repmode,   16)
  clmode  = default(clmode,     5)
  TwoPass = default(TwoPass, true)
  thSAD   = default(thSAD ,   150)
  thSADC  = default(thSADC, thSAD)
    
  ox      = input.width()
  oy      = input.height()
  HD      = (ox == 1920 || oy >= 800) ? true : false
  blksize = (HD == true) ? 16 : 8
  search  = (HD == true) ?  4 : 5
  overlap = blksize / 2

  src   = input
  PreNR = (GPU == true) ? src.NLMeansCL(h=radius * 1.5, plane=4).TemporalDeGrain(5, 9) : \
		   	  src.FFT3DFilter(sigma=radius * 2, plane=4, bw=16, bh=16, ow=8, oh=8, bt=3, wintype=1).TemporalDeGrain(5, 9)
  PreNR_super = MSuper(PreNR, hpad=4, vpad=4, pel=2, sharp=2)
  src_super   = MSuper(src,   hpad=4, vpad=4, pel=2, sharp=2, levels=1)

  bwv1  = MAnalyse(PreNR_super, blksize=blksize, search=search, isb=true,  delta=1, overlap=overlap, truemotion=true) 
  bwv2  = (radius >= 2) ? \
	  MAnalyse(PreNR_super, blksize=blksize, search=search, isb=true,  delta=2, overlap=overlap, truemotion=true) : BlankClip()
  bwv3  = (radius == 3) ? \
	  MAnalyse(PreNR_super, blksize=blksize, search=search, isb=true,  delta=3, overlap=overlap, truemotion=true) : BlankClip()
  fwv1  = MAnalyse(PreNR_super, blksize=blksize, search=search, isb=false, delta=1, overlap=overlap, truemotion=true) 
  fwv2  = (radius >= 2) ? \
	  MAnalyse(PreNR_super, blksize=blksize, search=search, isb=false, delta=2, overlap=overlap, truemotion=true) : BlankClip()
  fwv3  = (radius == 3) ? \
	  MAnalyse(PreNR_super, blksize=blksize, search=search, isb=false, delta=3, overlap=overlap, truemotion=true) : BlankClip()

  bcomp = MCompensate(src, src_super, bwv1) 
  fcomp = MCompensate(src, src_super, fwv1)
  
  NR1       = src.RemoveDirtSE(fcomp, bcomp, repmode=repmode, clmode=clmode)
  NR1_super = (TwoPass == true)  ? MSuper(NR1, hpad=4, vpad=4, pel=2, sharp=2, levels=1) : BlankClip()
  NR2       = (TwoPass == false) ? NR1
  \   	    : (radius == 1) ? MDeGrain1(NR1, NR1_super, bwv1, fwv1, thSAD=thSAD, thSADC=thSADC)
  \   	    : (radius == 2) ? MDeGrain2(NR1, NR1_super, bwv1, bwv2, fwv1, fwv2, thSAD=thSAD, thSADC=thSADC)
  \   	    : 		      MDeGrain3(NR1, NR1_super, bwv1, bwv2, bwv3, fwv1, fwv2, fwv3, thSAD=thSAD, thSADC=thSADC)

  return (NR2)
}

function TemporalDeGrain(clip input, int "mode", int "thr")
{
  mode = Default(mode, 5)
  thr  = Default(thr,  8)

  rg   = RemoveGrain(input, mode=mode)
  tr   = TemporalRepair(rg, input)
  fs   = FluxSmoothT(tr, thr)

  return (fs)
}

function RemoveDirtSE(clip input, clip fcomp, clip bcomp, int "repmode", int "clmode")
{
  repmode   = Default(repmode, 16)
  clmode    = Default(clmode,   5)

  clensed   = Interleave(fcomp, input, bcomp).Clense(cache=-1).selectevery(3, 1)
  sbegin    = ForwardClense(input, cache=-1)
  send      = BackwardClense(input, cache=-1)
  alt       = Repair(SCSelect(input, sbegin, send, clensed, debug=false), input, mode=repmode) 
  restore   = Repair(clensed, input, mode=repmode)
  corrected = RestoreMotionBlocks(clensed, restore, neighbour=input, alternative=alt, gmthreshold=50, \
                                  dist=1, dmode=2, debug=false, noise=8, noisy=12)
  postNR    = RemoveGrain(corrected, mode=clmode)

  return (postNR)
}
.
Connect all three parts to one file with AVSI extention (removedirt.avsi).
.
__________________
Warm and fuzzy (white and fluffy)

Last edited by Jenyok; 8th November 2014 at 13:03.
Jenyok is offline   Reply With Quote
Old 8th November 2014, 17:47   #173  |  Link
papcom
Registered User
 
Join Date: Feb 2002
Location: Southwest Germany
Posts: 169
Quote:
Originally Posted by Jenyok View Post
.
Connect all three parts to one file with AVSI extention (removedirt.avsi).
.
hi @yenyok - what can I do with Your giant script? How exactly is it to use?---on which material?

I did put it together but now... what shall I do further?
__________________
Lenovo Intel i7Quad/WIN8 - Virtual Dub 1.10.4/Avisinth 2.6MT- MacMini I7 QuadCore
papcom is offline   Reply With Quote
Old 8th November 2014, 18:00   #174  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,389
Quote:
Originally Posted by papcom View Post
hi @yenyok - what can I do with Your giant script? How exactly is it to use?---on which material?

I did put it together but now... what shall I do further?
He posted some variations on "remove dirt" . Each one is slightly different. In some scenarios one might work better than another. You will get better results if you tailor the settings to your source - this involves some tweaking and experimentation

Notice each one is a separate function. So like the previous one from John, you have to call them to "activate" them . It's unlikely that you would use all of them at once or serially
poisondeathray is offline   Reply With Quote
Old 8th November 2014, 18:04   #175  |  Link
papcom
Registered User
 
Join Date: Feb 2002
Location: Southwest Germany
Posts: 169
thank You @poisondeathray - why did he write that one shall connect them all to ONE file*
__________________
Lenovo Intel i7Quad/WIN8 - Virtual Dub 1.10.4/Avisinth 2.6MT- MacMini I7 QuadCore
papcom is offline   Reply With Quote
Old 8th November 2014, 18:24   #176  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,389
Quote:
Originally Posted by papcom View Post
thank You @poisondeathray - why did he write that one shall connect them all to ONE file*
For organizational purposes.

He just split them up into different posts. You can copy & paste into a single .avs or avsi

There are 100's or 1000's of filters, functions and their various variations for avisynth. It becomes messy in a hurry. If you don't have a system of organization, you will mix up filters, get the wrong version of .dlls, experience other problems....

Some people prefer to put some commonly used ones in a single .avsi, or multiple .avsi (.avsi are autoloading when placed in the plugins folder) . The more autoloading .dlls and .avsi's the slower avisynth will be on initialization

Other people prefer to manually load everything (either copy & past the function to the script as you are doing now, or manually LoadPlugin()

The point is you can organize it however you wish
poisondeathray is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:04.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.