VideoHelp Forum
+ Reply to Thread
Results 1 to 3 of 3
Thread
  1. 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
    Quote Quote  
  2. Why do you need that exact equation?

    Code:
    z = (1 - (1.124x - 9.466x^2 + 36.624x^3 - 45.47x^4 + 18.188x^5))^(y^2 * 10)
    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:
    ######################################################
    #
    #  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)
    }
    
    ######################################################
    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:

    Click image for larger version

Name:	curves.png
Views:	134
Size:	3.6 KB
ID:	43601

    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.
    Quote Quote  
  3. By the way, here is the basic equation:

    Code:
    z = (1 - (1.124x - 9.466x^2 + 36.624x^3 - 45.47x^4 + 18.188x^5))^(y^2 * 10)
    using AviSynth's mt_lut():

    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"))
    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:
    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"))
    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.

    Maybe someone else knows a better way to do this.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!