Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save WolframRhodium/3b0ca10fb859517782351836b0e295e8 to your computer and use it in GitHub Desktop.
Save WolframRhodium/3b0ca10fb859517782351836b0e295e8 to your computer and use it in GitHub Desktop.
BM3D
# Parameters
input = YUV420P16
# matrix = "709"
matrix = mvf.GetMatrix(input, matrix, True)
process_y = True
sigma_y = 2.0
basic_y_args = dict(profile="fast", group_size=8, bm_range=6)
process_uv = False
sigma_uv = 2.0
basic_uv_args = dict(profile="fast", group_size=6, bm_range=4)
# Process
if process_y:
RGB_y = core.resize.Bicubic(input, format=vs.RGBS, matrix_in_s=matrix, filter_param_a_uv=0, filter_param_b_uv=0.5, range_in_s="limited")
OPP_y = mvf.ToYUV(RGB_y, matrix='OPP')
flt_y = core.bm3d.Basic(OPP_y, matrix=100, sigma=[sigma_y, 0, 0], **basic_y_args)
flt_y = mvf.ToRGB(flt_y, matrix='OPP')
flt_y = core.resize.Bicubic(flt_y, format=vs.GRAY16, matrix_s=matrix, filter_param_a_uv=0, filter_param_b_uv=0.5, range_s="limited", dither_type='random')
else:
flt_y = input
if process_uv:
down = core.fmtc.resample(input, input.width // 2, input.height // 2, sx=-0.5, css='444', planes=[3, 2, 2])
RGB_uv = core.resize.Bicubic(down, format=vs.RGBS, matrix_in_s=matrix, filter_param_a_uv=0, filter_param_b_uv=0.5, range_in_s="limited")
OPP_uv = mvf.ToYUV(RGB_uv, matrix='OPP')
flt_uv = core.bm3d.Basic(OPP_uv, matrix=100, sigma=[0, sigma_uv, sigma_uv], **basic_uv_args)
flt_uv = mvf.ToRGB(flt_uv, matrix='OPP')
flt_uv = core.resize.Bicubic(flt_uv, format=vs.YUV444P16, matrix_s=matrix, filter_param_a_uv=0, filter_param_b_uv=0.5, range_s="limited", dither_type='random')
else:
flt_uv = input
flt = core.std.ShufflePlanes([flt_y, flt_uv], [0, 1, 2], vs.YUV)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment