View Single Post
Old 11th September 2018, 05:04   #19  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Zebra v1.07, new version see 1st post.

Code:
/* 
	v1.04, 15 Jan 2015. Added Zebroid.
	v1.05, 30 Mar 2015. changed RGB Matrix default, (c.width>1100 || c.height>600)?3[PC709]:2[REC601]
	       Recompile v2.6 dll with Avisynth Version 6 Header.
	v1.06, 15 Aug 2018. Added Version Resource. Recompile VS2008 Avs v2.58, AVs+ v2.60 x86 & x64.
	v1.07, 11 Sept 2018. Added MinTh, MaxTh, MnMx_MinTh, MnMx_MaxTh, FuncMap args.

*/
Mod of EQuid() Script, as supplied in Zip

Code:
Function Equid(clip c,Float "Thresh",Int "Lo",Int "Hi",Int "CMad",Int "Bands",
        \ Float "MinTh", Float "MaxTh",Float "MnMx_MinTh",Float "MnMx_MaxTh",Int "FuncMap",
        \ Bool "Zebroid",Float "zThresh",Int "zLo",Int "zhi",Int "zCMad",Int "zFunc",
        \ Float "zMinTh", Float "zMaxTh",Float "zMnMx_MinTh",Float "zMnMx_MaxTh",
        \ Bool "SubsI",Bool "SubsO"
        \ ) {
/*
        Equid, Hoofed mammal with Mane (or an on-line £1.00 coin).
            Equid, a ZebraTest() script mod, revamped as a script function.

        Shows Zebra Bands for clip c.
            Zebra bands selectable via Bands(default 6, ie all, from highest band downwards, so Bands=2 selects YInRange & AverageLuma)
                    or via a FuncMap bit map(default $3F ie all), where each set bit selects a Zebra band
                       (Where the min/max/minmaxdif default to Thresh).
                Bit 0, ($01), YPlaneMin(Threshold=MinTh)
                Bit 1, ($02), YPlaneMax(Threshold=MaxTh)
                Bit 2, ($04), YPlaneMinMaxDifference(MnMx_MinTh, MnMx_MaxTh)    # MinMaxDif band has individually selectable thresholds
                Bit 3, ($08), YPlaneMedian
                Bit 4, ($10), AverageLuma
                Bit 5, ($20), YInRange(lo=Lo,hi=Hi)
            By Default All Bands are $3F, dec 63.

        Thresh,     Default 0.0, is group default setting for the minimum and maximum thresholds.
        lo,hi,      Defaults Lo=128, hi=255 YInRange(Lo,hi) band. YInRange shows population between lo and high (where white=100%).
        Bands,      Default 6, as described above. (selects from highest band [YInRange] downwards). (0=none selected).
        MinTh,      Default Thresh. Threshold for YPlaneMin band.
        MaxTh,      Default Thresh. Threshold for YPlaneMax band.
        MnMx_MinTh, Default Thresh. Threshold for YPlaneMinMaxDifference(Minimum threshold), individually selectable threshold.
        MnMx_MaxTh, Default Thresh. Threshold for YPlaneMinMaxDifference(Maximum threshold), individually selectable threshold.
        FuncMap,    Default $3F, dec 63m, ie all bands selected. (0=none selected).

        Zebroid,    Default False.
                      In addition to the normal Zebra() functionality provided in ZebraTest script, this effort allows selection of
                    Zebroid functionality (when Zebroid bool = true, where the 'z...' args become relevant).
                    If Zebroid is applied to the incoming clip, then the Zebra bands are created using the Zebroid result as source.
                    q) Whats its purpose ?, a) Dont know, just experiment.
        zXXX args,  As For above args but only if Zebroid=True, and applied to incoming Zebroid'ed clip before Zebra bands created.

        SubsI,      Default True, If True, show subtitles on inner  clip (source of Zebroid).
        SubsO,      Default SubI, If True, show subtitles on outter clips, Zebra bands if selected.

        NOTE, Can only supply EITHER Bands OR FuncMap, not both, and if suppled as 0, and Zebroid=False, then function returns src clip.
*/
    myName="EQuid: "
    c  PIX=48
    Assert(!(Bands.Defined && FuncMap.Defined),RT_String("%sCannot specify both Bands and FuncMap",myName))
    FuncMap  = !FuncMap.Defined ? RT_BitXor($3F,RT_BitLSR($3F,Default(Bands,6))) : FuncMap
    Thresh     =Default(Thresh,0.0)           Lo=Default(Lo,128)   Hi=Default(Hi,255)  CMad=Default(CMad,1)  Bands=Default(Bands,4)
    MinTh      =Default(MinTh,Thresh)         MaxTh=Default(MaxTh,Thresh)
    MnMx_MinTh =Default(MnMx_MinTh,Thresh)    MnMx_MaxTh=Default(MnMx_MaxTh,Thresh)
    Zebroid    =Default(Zebroid,false)        zThresh=Default(zThresh,0.0)
    zLo        =Default(zLo,128)              zHi=Default(zHi,255)
    zCMad      =Default(zCMad,1)              zFunc=Default(zFunc,4)
    zMinTh     =Default(zMinTh,zThresh)       zMaxTh=Default(zMaxTh,zThresh)
    zMnMx_MinTh=Default(zMnMx_MinTh,zThresh)  zMnMx_MaxTh=Default(zMnMx_MaxTh,zThresh)
    SubsI=Default(SubsI,True)                 SubsO=Default(SubsO,SubsI)
    Zebroid?Assert(0 <= zFunc <= 5,RT_String("%s0 <= zFunc <= 5(%.0f)",myName,zFunc)):NOP
    zFnName=Select(zFunc,"Min","Max","Mx-Mn","Med","Ave","Yir")
    (Zebroid) ? Zebroid(Threshold=zThresh,lo=Round(zLo),hi=Round(zHi),cmad=zCMad,func=zFunc,
            \       MinTh=zMinTh,Maxth=zMaxTh,MnMx_MinTh=zMnMx_MinTh,MnMx_MaxTh=zMnMx_MaxTh)
            \ : NOP
    Bands=RT_BitSetCount(FuncMap)
    Z1=(Bands==0)?0:Last.Zebra(row=true,threshold=Thresh,lo=Round(LO),hi=Round(HI),pix=PIX,cmad=CMAD,
            \ MinTh=MinTh,Maxth=MaxTh,MnMx_MinTh=MnMx_MinTh,MnMx_MaxTh=MnMx_MaxTh,FuncMap=FuncMap)
    Z2=(Bands==0)?0:Zebra(row=false,threshold=Thresh,lo=Round(LO),hi=Round(HI),pix=PIX,cmad=CMAD,
            \ MinTh=MinTh,Maxth=MaxTh,MnMx_MinTh=MnMx_MinTh,MnMx_MaxTh=MnMx_MaxTh,FuncMap=FuncMap)
    S1=(!SubsI) ? "" : RT_String("\nMinTh=%.2f MaxTh=%.2f\nMnMx_MinTh=%.2f  MnMx_MaxTh=%.2f\nLo=%d Hi=%d\nCMad=%d",
                 \ Minth,MaxTh,MnMx_MinTh,MnMx_MaxTh,Lo,Hi,CMad)
    S2=(!(SubsI&&Zebroid)) ? "" : RT_String("\n\nzMinTh=%.2f zMaxTh=%.2f\nzMnMx_MinTh=%.2f  zMnMx_MaxTh=%.2f\nzLo=%d zHi=%d\nzCMad=%d",
                 \ zMinth,zMaxTh,zMnMx_MinTh,zMnMx_MaxTh,zLo,zHi,zCMad)
    S=S1+S2      Lines=RT_TxtQueryLines(S)    Y=(Height-Lines*18) / 2   S=S.RT_StrReplace(Chr(10),"\n")
    Z1=(Bands!=0&&SubsO)?Z1.SUBTITLE("Row\nTrue",Align=5,lsp=0):Z1
    Z2=(Bands!=0&&SubsO)?Z2.SUBTITLE("Row False",y=(Z2.Height+12)/2.0,Align=5):Z2
    (SubsI) ? SubTitle(S,Align=5,Y=Y,lsp=0) : NOP
    Function BandSub(clip c,int FuncMap,Int Bands) {
        c  myName="EQuid::BandSub: "
        IsAvsPlus=(FindStr(UCase(versionString),"AVISYNTH+")!=0) HasGScript=RT_FunctionExist("GScript")
        Assert(IsAvsPlus || HasGScript,RT_String("%sNeed Avs+ or GScript",myName))
        GS="""
            off=0 PixX=Width.Float/Bands PixY=Height.Float/Bands
            for(i=0,5) {
                if(RT_BitTst(FuncMap,i)) {
                    Fnam=Select(i,"Min","Max","Mx-Mn","Med","Ave","Yir")
                    len=StrLen(Fnam)    x=(Off+0.5)*PixX-(4.5*Len) y=(Off+0.5)*PixY-11
                    SUBTITLE(fnam,x=x,y=y)
                    off = off + 1
                }
            }
        """
        HasGScript?GScript(GS) : Eval(GS)
        Return Last
    }
    BLANK=(Z2.IsClip)?Z2.BlankClip(width=Z1.Width,color=$808080):0
    Blank=(Blank.IsClip&&SubsO)?Blank.BandSub(FuncMap,Bands):Blank
    Return (Blank.IsClip)?StackVertical(StackHorizontal(Z1),StackHorizontal(Z2,BLANK)):Last
}

/*
    #Client_script
    AVISource("D:\G.avi")
    #Colorbars.KillAudio
    Crop(0,0,Width/4*4,Height/4*4)
    ConvertToYV12
    FUNCMAP = $3f  # 0 -> $3F
    return Equid(FuncMap=FUNCMAP)
*/
EDIT:
Code:
AVISource("D:\Greymouse.avi")
Crop(12,12,-12,-12)
Crop(0,0,Width/4*4,Height/4*4)
ConvertToYV12
FUNCMAP = $2C   # bits 2, 3, and 5, YPlaneMinMaxdif, YPlaneMedian, YInRange
return Equid(MnMx_MinTh=5,MnMx_MaxTh=10,Lo=140,hi=255,FuncMap=FUNCMAP)
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 11th September 2018 at 05:30.
StainlessS is offline   Reply With Quote