![]() |
|
Feature Request: add adaptive grain filter - Printable Version +- Selur's Little Message Board (https://forum.selur.net) +-- Forum: Hybrid - Support (https://forum.selur.net/forum-1.html) +--- Forum: Problems & Questions (https://forum.selur.net/forum-3.html) +--- Thread: Feature Request: add adaptive grain filter (/thread-1689.html) |
Feature Request: add adaptive grain filter - Dan64 - 19.01.2021 Hello Selur, It could be useful add in Hybrid the AdaptiveGrain filter described in this article: https://blog.kageru.moe/legacy/adaptivegrain.html In summary the filter described aims to apply the optimal amount of grain to all scenes to prevent banding artifacts without having a significant impact on the perceived image quality or the required bitrate. The filter can be downloaded here: https://git.kageru.moe/kageru/adaptivegrain/releases/tag/0.3.1 Thanks RE: Feature Request: add adaptive grain filter - Selur - 20.01.2021 I'll look at it after work today or tomorrow. Cu Selur RE: Feature Request: add adaptive grain filter - Selur - 20.01.2021 Okay, first 'hurdle': What are the min/max values for strength&luma_scaling? Wild guess would be: strength 0-1 and luma_scaling 0-100 But I see no info about it,.. RE: Feature Request: add adaptive grain filter - Selur - 20.01.2021 Okay, since I don't know how to get kagefunc working in a portable Vapoursynth, I tried to guess how this is might work: I tried: # Imports
import os
import sys
import vapoursynth as vs
core = vs.get_core()
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/GrainFilter/AdaptiveGrain/adaptivegrain_rs.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
# source: 'F:\TestClips&Co\files\10bit Test.mkv'
# current color space: YUV420P10, bit depth: 10, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading F:\TestClips&Co\files\10bit Test.mkv using LWLibavSource
clip = core.lsmas.LWLibavSource(source="F:/TestClips&Co/files/10bit Test.mkv", format="YUV420P10", cache=0)
# making sure input color matrix is set as 470bg
clip = core.resize.Point(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# adding Grain using AdaptiveGrain
clip = core.std.PlaneStats(clipa=clip) # calculate stats
mask = core.adg.Mask(clip=clip, luma_scaling=12) # calculate mask
grained = core.grain.Add(clip, var=0.25, constant=True) # create grained version
clip = core.std.MaskedMerge(clip, grained, mask) # only use grained version according to mask
# adjusting output color from: YUV420P10 to YUV420P8 for x264Model (i420@10)
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()-> do you know whether this is correct? Cu Selur RE: Feature Request: add adaptive grain filter - Selur - 20.01.2021 Send you a link to a dev version via PM, which uses the adaptive grain option like I showed in the post above. Not totally sure this is correct. Cu Selur RE: Feature Request: add adaptive grain filter - Dan64 - 21.01.2021 The dev version is working as expected. Using the adaptive Luma scaling the grain is less visible in brighter scenes, while it is more evident in dark scenes, as it should be. Thanks!
|