_Al_
3rd September 2020, 06:21
Trying to calculate manually convolution, it looks ok but just it is brighter. Not sure what is wrong, with expression calculations or something else. If matrix = [1,1,1,1,1,1,1,1,1], then it is same as vapoursynth function though.
clip = core.std.BlankClip().sub.Subtitle('Bluring Test', sar=4)
#manual convolution calculations:
shifts = [
(-1,-1), (0,-1), (1,-1),
(-1, 0), (0, 0), (1, 0),
(-1, 1), (0, 1), (1, 1)
]
#9 clips , each shifted accordingly so they can be used in expressions at the same time:
clips = [ clip.resize.Point(src_left=src_left, src_top=src_top) for src_left, src_top in shifts]
m = [1, 2, 1, 2, 4, 2, 1, 2, 1] #kernel for convolution that is avisynth's blur 1
manual_conv = core.std.Expr(clips, [f'x {m[0]} * y {m[1]} * + z {m[2]} * + a {m[3]} * + b {m[4]} * + c {m[5]} * + d {m[6]} * + e {m[7]} * + f {m[8]} * + 9 /']*3)
#regular vapoursynth convolution:
conv = core.std.Convolution(clip, matrix = m)
from view import Preview
Preview([clip, manual_conv, conv]) #manual calculation looks brighter
clip = core.std.BlankClip().sub.Subtitle('Bluring Test', sar=4)
#manual convolution calculations:
shifts = [
(-1,-1), (0,-1), (1,-1),
(-1, 0), (0, 0), (1, 0),
(-1, 1), (0, 1), (1, 1)
]
#9 clips , each shifted accordingly so they can be used in expressions at the same time:
clips = [ clip.resize.Point(src_left=src_left, src_top=src_top) for src_left, src_top in shifts]
m = [1, 2, 1, 2, 4, 2, 1, 2, 1] #kernel for convolution that is avisynth's blur 1
manual_conv = core.std.Expr(clips, [f'x {m[0]} * y {m[1]} * + z {m[2]} * + a {m[3]} * + b {m[4]} * + c {m[5]} * + d {m[6]} * + e {m[7]} * + f {m[8]} * + 9 /']*3)
#regular vapoursynth convolution:
conv = core.std.Convolution(clip, matrix = m)
from view import Preview
Preview([clip, manual_conv, conv]) #manual calculation looks brighter