MfRainbow

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (Shared functions/mfRainbow moved to MfRainbow: Remove obsolete shared functions category. See Talk:External filters.)
 
m (1 revision)

Revision as of 22:34, 9 May 2013

Ok, cause I couldn't find a working 2.5 version of AntiBlink, I decided to make my own ^^'.

# mfRainbow by mf
# Derainbows according to the same principle as AntiFlicker.
# Definitely slower, but possibly (untested) higher quality.
#
# I don't claim copyright but I ask you to treat my script
# fairly.
#
# Happy slow encoding ^^.
#

function mfRainbow(clip input, string "mode", float "clipstren", int "strength", bool "post")
{
   mode      = Default(mode, "slowest") # processing speed, slow-slower-slowest
   strength  = Default(strength, 255)   # processing strength, 0-255
   clipstren = Default(clipstren, 5.0)  # value clipping strength, 0.0-10.0
   post      = Default(post, true)      # spatial postprocessing on/off

   inputrgb = input.ConvertToRGB32()

   edgemask = input.EdgeMask(0, "sobel").Inflate().GreyScale().
     \  Levels(0, clipstren, 255, 0, 255).ConvertToRGB32()

   derainbow = (mode == "slow") ? input.Deen("a3d",4,0,40,50) : 
     \  (mode == "slower") ? input.Deen("a3d",4,0,20,50).Deen("a3d",4,0,20,50) : 
     \  (mode == "slowest") ? input.Deen("a3d",4,0,15,50).Deen("a3d",4,0,15,50).
     \  Deen("a3d",4,0,15,50).Deen("a3d",4,0,15,50) : Assert(false, "available modes: 
     \  slow, slower, slowest")

   maskedrainbow = Mask(derainbow.ConvertToRGB32(), edgemask)
   edgerainbow = Layer(inputrgb, maskedrainbow, "add", strength)

   semifinal = input.MergeChroma(edgerainbow.ConvertToYV12())
   blah = semifinal.MSmooth() # cause of a weird argument error
   final = semifinal.MergeChroma(blah)

   return post ? final : semifinal
 }

Parameters:

type - name - description - range - default

string mode - processing speed (and quality) - slow/slower/slowest - slowest

int strength - processing strength - 0-255 - 255

float clipstren - value clipping strength - 0.0-10.0 - 5.0

bool post - spatial postprocessing - true/false - true

"Slow" mode might cause chroma ghosting on edges. Slowest is the safest, but might not be as effective as slow.

Explanation of clipstren: this works like value boosts in mfToon, it's the gamma correction of the mask ^^'. Lower values give more variation, but less strength.

You need Deen, MaskTools and MSmooth.

Like before (and probably ever again), I don't check colorspaces cause I'm too lazy, and my function always outputs YV12. Who needs another colorspace anyway. I'm still kinda sad about the fact that Layer and Mask don't work in YUV (cause of the lack of an AYUV colorspace), so alas I have to do 2 colorspace conversions, namely to RGB and back. (Note Wilbert: note that there is a Layer/Mask equivalent working in YUV nowadays, so the script could be adjusted without those colorspace conversions.) The luma luckily doesn't have to be touched (and I do MergeChroma to ensure that), so that minimizes conversion errors.

Please test if this is any better or worse than existing derainbowers. A discussion can be found here.

Personal tools