View Single Post
Old 24th January 2022, 18:21   #2  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,352
This is a cheap approach in YUV.
Code:
function GreyWorld(clip a) {

rgb  = isRGB(a)
isy  = isy(a)
px   = PixelType(a)
bi   = BitsPerComponent(a)
fs   = propNumElements (a,"_ColorRange")  > 0 ? \
       propGetInt      (a,"_ColorRange") == 0 : rgb
       
ScriptClip(a,function[bi,fs,px] () {

    U  = PlaneMinMaxStats(0, 0, 1, false)
    V  = PlaneMinMaxStats(0, 0, 2, false)
    H  = ex_bs(128,  8, bi, true, float=true)
    U  = H - U[4]
    V  = H - V[4]

    Expr(last,SwapUV(),"",Format("x {U} +"),Format("x {V} +"), Format=px)
} ) }
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote