Soulhunter
25th February 2007, 23:30
Ok, here are two new functions from mf:
# MotionThresh by mf
# Simple scenechange-proof motion threshold
# Tile outputs 16x16 clip for speed
# Use tile=true for conditional filtering, tile=false for masking
function MotionThresh(clip input, float thresh, bool "tile") {
tile = Default(tile, false)
black = BlankClip(input, width=16, height=16)
white = BlankClip(input, width=16, height=16, color=$FFFFFF)
cond1 = ConditionalFilter(input, white, black, "YDifferenceFromPrevious()", "greaterthan", String(thresh))
cond2 = ConditionalFilter(input, white, black, "YDifferenceToNext()", "greaterthan", String(thresh))
Overlay(cond1, cond2, mode="darken")
tile ? last : PointResize(input.width, input.height)
}
# MotionRamp by mf
# Average motion soft-thresholding based on 5 thresholds
# Dependancies: MotionThresh, BlendMulti
function MotionRamp(clip input, int thresh1, int thresh2, int thresh3, int thresh4, int thresh5, int "min", int "max", int "floor", int "ceil", int "radius", bool "tile") {
min = Default(min, 0)
max = Default(max, 255)
floor = Default(floor, 0)
ceil = Default(ceil, 255)
radius = Default(radius, 2)
tile = Default(tile, false)
input
BlendMulti(MotionThresh(thresh1, tile=true), MotionThresh(thresh2, tile=true), MotionThresh(thresh3, tile=true), MotionThresh(thresh4, tile=true), MotionThresh(thresh5, tile=true))
TemporalSoften(radius,255,0,255,2)
Levels(floor, 1, ceil, min, max)
ColorYUV(levels="TV->PC")
tile ? last : PointResize(input.width, input.height)
}
Basically they translate the motion amount of a frame -> a luminance value which can be used to remote adjust filters... This can be used to raise the strength of a denoiser more n more as higher the motion gets [very useful to get some extra % compressibility as you wont notice the loss of fine details in high motion scenes anyway] :]
# Example:
# More Motion -> More Denoising via FFT3DFilter
Input=Last
Input
MotionRamp(5,10,15,20,25,Max=255,Tile=True)
MotionRamp=Last
Input
ScriptClip("Overlay(Last,Input,Opacity=AverageLuma(MotionRamp)/100)")
ScriptClip("FFT3DFilter(Sigma=(AverageLuma(MotionRamp)/2/2/2/2))")
You can also use this functions to raise denoising strength depending on the noise amount... Useful for sources where the noise amount changes from scene to scene!
# Example:
# More Noise -> More Denoising via FFT3DFilter
Input=Last
Deen("a2d",3,10,10)
Subtract(Last,Input)
Levels(120,1,137,0,255)
MotionRamp(5,10,15,20,25,Max=255,Tile=True)
MotionRamp=Last
Input
#ScriptClip("Subtitle(String(Round(AverageLuma(ramp))))")
ScriptClip("Overlay(Last,Input,Opacity=AverageLuma(MotionRamp)/100)")
ScriptClip("FFT3DFilter(Sigma=(AverageLuma(MotionRamp)/2/2/2/2))")
But there are much more possibilitys, just play around with it!
Btw, the BlendMulti plugin can be found here... (http://mf.creations.nl/avs/filters/)
Have fun ~Bye
# MotionThresh by mf
# Simple scenechange-proof motion threshold
# Tile outputs 16x16 clip for speed
# Use tile=true for conditional filtering, tile=false for masking
function MotionThresh(clip input, float thresh, bool "tile") {
tile = Default(tile, false)
black = BlankClip(input, width=16, height=16)
white = BlankClip(input, width=16, height=16, color=$FFFFFF)
cond1 = ConditionalFilter(input, white, black, "YDifferenceFromPrevious()", "greaterthan", String(thresh))
cond2 = ConditionalFilter(input, white, black, "YDifferenceToNext()", "greaterthan", String(thresh))
Overlay(cond1, cond2, mode="darken")
tile ? last : PointResize(input.width, input.height)
}
# MotionRamp by mf
# Average motion soft-thresholding based on 5 thresholds
# Dependancies: MotionThresh, BlendMulti
function MotionRamp(clip input, int thresh1, int thresh2, int thresh3, int thresh4, int thresh5, int "min", int "max", int "floor", int "ceil", int "radius", bool "tile") {
min = Default(min, 0)
max = Default(max, 255)
floor = Default(floor, 0)
ceil = Default(ceil, 255)
radius = Default(radius, 2)
tile = Default(tile, false)
input
BlendMulti(MotionThresh(thresh1, tile=true), MotionThresh(thresh2, tile=true), MotionThresh(thresh3, tile=true), MotionThresh(thresh4, tile=true), MotionThresh(thresh5, tile=true))
TemporalSoften(radius,255,0,255,2)
Levels(floor, 1, ceil, min, max)
ColorYUV(levels="TV->PC")
tile ? last : PointResize(input.width, input.height)
}
Basically they translate the motion amount of a frame -> a luminance value which can be used to remote adjust filters... This can be used to raise the strength of a denoiser more n more as higher the motion gets [very useful to get some extra % compressibility as you wont notice the loss of fine details in high motion scenes anyway] :]
# Example:
# More Motion -> More Denoising via FFT3DFilter
Input=Last
Input
MotionRamp(5,10,15,20,25,Max=255,Tile=True)
MotionRamp=Last
Input
ScriptClip("Overlay(Last,Input,Opacity=AverageLuma(MotionRamp)/100)")
ScriptClip("FFT3DFilter(Sigma=(AverageLuma(MotionRamp)/2/2/2/2))")
You can also use this functions to raise denoising strength depending on the noise amount... Useful for sources where the noise amount changes from scene to scene!
# Example:
# More Noise -> More Denoising via FFT3DFilter
Input=Last
Deen("a2d",3,10,10)
Subtract(Last,Input)
Levels(120,1,137,0,255)
MotionRamp(5,10,15,20,25,Max=255,Tile=True)
MotionRamp=Last
Input
#ScriptClip("Subtitle(String(Round(AverageLuma(ramp))))")
ScriptClip("Overlay(Last,Input,Opacity=AverageLuma(MotionRamp)/100)")
ScriptClip("FFT3DFilter(Sigma=(AverageLuma(MotionRamp)/2/2/2/2))")
But there are much more possibilitys, just play around with it!
Btw, the BlendMulti plugin can be found here... (http://mf.creations.nl/avs/filters/)
Have fun ~Bye