my friends a huge favor this feature only applies banding to black areas would be possible to migrate the script to avisynth please
https://kageru.moe/article.php?p=adaptivegrain
Vapoursynth script
https://kageru.moe/blog/adaptivegrain.py
a lot of people fight against banding, I hope you can help us , thanks so so much
+ Reply to Thread
Results 1 to 3 of 3
-
-
Why do you need that exact equation?
Is there some magic in it? I don't know any way to make a runtime filter with a runtime variable. But here's a function that does something similar:Code:z = (1 - (1.124x - 9.466x^2 + 36.624x^3 - 45.47x^4 + 18.188x^5))^(y^2 * 10)
The "adj" value lets you increase or decrease it a bit. At the default adj value, and average luma's close to those in his graph:Code:###################################################### # # Build an alpha mask that varies with average luma. # ###################################################### function GammaMaskRT(clip vid) { avg = vid.AverageLuma() gam = (avg-150)*1.4 ColorYUV(vid, gamma_y=gam).ColorYUV(gain_y=256).Invert() } ###################################################### function GammaMask(clip vid, int "adj") { adj = Default (adj, 0) ScriptClip(vid, "GammaMaskRT()") ColorYUV(gain_y=adj) } ######################################################
But I don't necessarily agree that only dark shots and dark areas need added grain. Where you need added grain is in smooth gradients, no matter how light or dark. I often see posterization in bright cyan/grey skies, for example. -
By the way, here is the basic equation:
using AviSynth's mt_lut():Code:z = (1 - (1.124x - 9.466x^2 + 36.624x^3 - 45.47x^4 + 18.188x^5))^(y^2 * 10)
AVG is the average luma of the frame. The problem is that mt_lut() doesn't accept runtime variables. So you would have to use something like:Code:mt_lut(mt_polish("(1 - (1.124*(x/255.0) - 9.466*((x/255.0)^2) + 36.624*((x/255.0)^3) - 45.47*((x/255.0)^4) + 18.188*((x/255.0)^5)) ) ^ ((AVG/255.0)^2 * 10) * 255.0"))
That uses two different curves, one when the average luma is below 128, the other when it is 128 or more. Of course, you could use as many different bands as you like.Code:AVG = AverageLuma() AVG < 128 ? mt_lut(mt_polish("(1 - (1.124*(x/255.0) - 9.466*((x/255.0)^2) + 36.624*((x/255.0)^3) - 45.47*((x/255.0)^4) + 18.188*((x/255.0)^5)) ) ^ ((180/255.0)^2 * 10) * 255.0")) \ : mt_lut(mt_polish("(1 - (1.124*(x/255.0) - 9.466*((x/255.0)^2) + 36.624*((x/255.0)^3) - 45.47*((x/255.0)^4) + 18.188*((x/255.0)^5)) ) ^ (( 85/255.0)^2 * 10) * 255.0"))
Maybe someone else knows a better way to do this.
Similar Threads
-
Qt Vapoursynth simple viewer example?
By Selur in forum ProgrammingReplies: 3Last Post: 20th Mar 2018, 12:02 -
[avisynth] what is the deinterlace method that use less CPU?
By marcorocchini in forum Newbie / General discussionsReplies: 5Last Post: 9th Nov 2015, 19:55 -
vapoursynth
By logicom in forum Video ConversionReplies: 0Last Post: 1st Dec 2014, 08:26 -
Avisynth PAL to NTSC Conversion method for best picture quality?
By VideoFanatic in forum RestorationReplies: 11Last Post: 11th Jun 2013, 10:29 -
anyone try VapourSynth yet?
By deadrats in forum EditingReplies: 0Last Post: 28th Dec 2012, 19:41


Quote