Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 8th September 2013, 03:57   #21  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
M53, find here fix for previous post edit bug, + mods + Docs.

MRgbChanStats() v1.03Beta, Here:
LINK REMOVED

Code:
MRgbChanStats(), Avisynth v2.5 Plugin by StainlessS

RGB32, RGB24 source clip. (Optional Mask clip Planar ONLY [v2.6 colorpspaces OK])

The compiletime/runtime clip functions share some common characteristics:-

The source clip c must be RGB32 or RGB24.
The optional Planar mask clip, governs which pixels are processed by the functions. Where a luma pixel in selected area of the the mask clip is
in range "MaskMin" to "MaskMax" inclusive, then those pixels will be processed.
Mask MUST, be same dimensions and have at least the same number of frames as clip c.
NOTE, as Mask clip now optional, to supply a Mask, you MUST explicitly supply BOTH source clip and Mask clip args, a single clip
will be interpreted as source clip without mask (as will no clips at all, where implicit Last clip would be used as source clip).
A Maskless function call will process all pixels in the selected area.

The 'n' arg is an optional frame number and defaults to 'current_frame' if not specified.
The x,y,w,h, coords specify the source rectangle under scrutiny and are specified as for Crop(), the default 0,0,0,0 is full frame.
If 'interlaced' is true, then every other line is ommited from the scan, so if eg y=1, then scanlines 1,3,5,7 etc are scanned,
if eg y=4 then scanlines 4,6,8,10 etc are scanned. The 'h' coord specifies the full height scan ie same whether interlaced is true
or false, although it will not matter if the 'h' coord is specified as eg odd or even, internally the height 'h' is reduced by 1
when interlaced=true and 'h' is even.

The Chan arg specifies which R or G or B channel to process [the multi-functional MRgbChanStats() function also allows a Chan arg of -1,
which processes R and G and B simulaneously for all functions selected by flgs arg, also allowed is chan arg of -2 which additionally
processes the ALPHA channel if RGB32 but throws an error if RGB24].
Default Chan is 0 (Red), 1 = Green, 2=Blue channel and 3=ALPHA channel when RGB32 ONLY else error.

***
***
***

MRgbChanMin(clip c,clip "mask"=NOTUSED,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,
        bool "interlaced"=false,float "threshold"=0.0,
        int "chan"=0, int "MaskMin"=128,"MaskMax"=255)
  Return int -1, if no valid pixels in Mask clip.
  Returns int minimum value (0 -> 255) in frame(n+delta) for area x,y,w,h, and selected Chan channel (0=R,1=G,2=B, RGB32 3=ALPHA)
  Threshold is a percentage, stating how many percent of the pixels are allowed below minimum (ignore extreme pixels ie noise).
  Threshold is % of all pixels in selected area if Maskless, OR % of valid mask pixels processed if Mask supplied.
  The threshold is optional and defaults to 0.0.

***
***
***

MRgbChanMax(clip c,clip "mask"=NOTUSED,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,
        bool "interlaced"=false,float "threshold"=0.0,
        int "chan"=0, int "MaskMin"=128,"MaskMax"=255)
  Return int -1, if no valid pixels in Mask clip.
  Returns int maximum value (0 -> 255) in frame(n+delta) for area x,y,w,h, and selected Chan channel (0=R,1=G,2=B, RGB32 3=ALPHA)
  Threshold is a percentage, stating how many percent of the pixels are allowed above maximum (ignore extreme pixels ie noise).
  Threshold is % of all pixels in selected area if Maskless, OR % of valid mask pixels processed if Mask supplied.
  The threshold is optional and defaults to 0.0

***
***
***

MRGBChanMinMaxDifference(clip c,clip "mask"=NOTUSED,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,
        bool "interlaced"=false,float "threshold"=0.0,
        int "chan"=0, int "MaskMin"=128,"MaskMax"=255)
  Return int -1, if no valid pixels in Mask clip.
  Returns int channel range [maximum - minimum difference] (0 -> 255) in frame(n+delta) for area x,y,w,h, and selected Chan channel
    (0=R,1=G,2=B, RGB32 3=ALPHA)
  Threshold is a percentage, stating how many percent of the pixels are allowed below minimum or above maximum (ignore extreme pixels ie noise).
  Threshold is % of all pixels in selected area if Maskless, OR % of valid mask pixels processed if Mask supplied.
  The threshold defaults to 0.0

***
***
***

MRGBChanMedian(clip c,clip "mask"=NOTUSED,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,bool "interlaced"=false,
     int "chan"=0,int "MaskMin"=128,"MaskMax"=255)
  Return int -1, if no valid pixels in Mask clip.
  Returns int channel median [equiv MRgbChanMin(threshold=50.0)] (0 -> 255) in frame(n+delta) for area x,y,w,h, and selected Chan channel
    (0=R,1=G,2=B, RGB32 3=ALPHA)

***
***
***

MRGBChanAve(clip c,clip "mask"=NOTUSED,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,bool "interlaced"=false,
    int "chan"=0,int "MaskMin"=128,"MaskMax"=255)
  Return int -1, if no valid pixels in Mask clip.
  Returns FLOAT average channel value (0.0 -> 255.0) in frame(n+delta) for area x,y,w,h, and selected Chan channel (0=R,1=G,2=B, RGB32 3=ALPHA).

***
***
***

MRGBChanStdev(clip c,clip "mask"=NOTUSED,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,bool "interlaced"=false,
    int "chan"=0,int "MaskMin"=128,"MaskMax"=255)
  Return int -1, if no valid pixels in Mask clip.
  Returns FLOAT Standard Deviation channel value(0.0 -> 255.0) in frame(n+delta) for area x,y,w,h, and selected Chan channel
    (0=R,1=G,2=B, RGB32 3=ALPHA)
  Standard Deviation. http://en.wikipedia.org/wiki/Standard_deviation

***
***
***

MRGBChanInRange(clip c,clip "mask"=NOTUSED,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,bool "interlaced"=false,
      int "chan"=0,int "lo"=128,int "hi"=lo,int "MaskMin"=128,"MaskMax"=255)
  Return int -1, if no valid pixels in Mask clip.
  Returns FLOAT value (0.0 -> 1.0) being the amount of pixels in the range "lo" to "hi" (inclusive) in frame(n+delta) for area x,y,w,h,
  and selected Chan channel (0=R,1=G,2=B, RGB32 3=ALPHA), 1.0 is equivalent to 100%.
  Implemented as requested by Martin53 (thankyou), NOTE, differs from other funcs that return range 0.0 to 255.0.
  NOTE, lo defaults to 128, "hi" defaults to "lo".

***
***
***

MRGBChanPNorm(clip c,clip "mask"=NOTUSED,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,bool "interlaced"=false,
      int "chan"=0,float "mu"=0.0,int "d"=1,int "p"=1,int "u"=1, int "MaskMin"=128,"MaskMax"=255)
  Return int -1 if no valid pixels in Mask clip.
  Returns FLOAT value greater or equal to 0.0, being the "Minkowski P-norm" (range depends upon values of 'd' and 'u') for frame(n+delta)
  area x,y,w,h, and selected Chan channel (0=R,1=G,2=B, RGB32 3=ALPHA)
  mu, Float, default 0.0 (0.0 -> 255.0)
  d,  int,   default 1 (1 -> 255)       # downscale
  p,  int,   default 1 (1 -> 16)        # power
  u,  int,   default 1 (1 -> 255)       # final upscale before returning result (experimental)
  Formula is: sum_over_pixels[ ((pixel-mu)/d)^p ]^(1/p) * u
  or in words: d and u are scaling aids. The differences between the pixel values and mu are scaled, taken to the power of p and added up
  over the frame. The sum is taken to the p-th root and finally rescaled.
  mu=0, d=1, p=1, u=1 yields the average.
  mu=average, d=1, p=2, u=1 yields the standard deviation (uncorrected sample standard deviation).
  Implemented as requested by Martin53 (thankyou).
  http://en.wikipedia.org/wiki/P-norm#The_p-norm_in_finite_dimensions
  http://en.wikipedia.org/wiki/Minkowski_distance

***
***
***

MRGBChanStats(clip c,clip "mask"=NOTUSED,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,bool "interlaced"=false,
      float "threshold"=0.0,int "chan"=0,int "lo"=128,int "hi"=lo,int "flgs"=255,string "prefix"="MRCS_",int "MaskMin"=128,"MaskMax"=255,
      float "mu"=0.0,int "d"=1,int "p"=1,int "u"=1)
  Returns multiple results as for above single frame RGB channel sampling functions as Global Variables (prefixed with the prefix string arg).
  The args up to "interlaced", are as for all other clip functions, "threshold" used only for "MRgbChanMin", "MRgbChanMax" and
  "MRGBChanMinMaxDifference" equivalent routines with same functionality.
  "lo" and "hi" are used only with the "MRGBChanInRange" equivalent routine with same functionality.
  "mu" and "d" and "p" and "u" are used only with the "MRGBChanPNorm" equivalent routine with same functionality.
  The new arg "Flgs" selects which results you want returned and the string "Prefix" that is prepended
  to the returned global variable names.
  The actual return result is a copy of the flgs args with any non valid bits reset, ie the global variables that were set.
  Global variables are NOT altered for any function not selected in flgs.
  EDIT: Returns 0 if no pixels found in search area of mask within MaskMin and MaskMax.

  Flgs_Bit_Number   Add_To_Flgs     Equivalent_Function             Global_Var_Set_Excluding_Prefix_and_Chan_postfix
     0                 1($01)        MRGBChanMin()                     "Min"        (0->255)
     1                 2($02)        MRGBChanMax()                     "Max"        (0->255)
     2                 4($04)        MRGBChanMinMaxDifference()        "MinMaxDiff" (0->255)
     3                 8($08)        MRGBChanMedian()                  "Med"        (0->255)
     4                16($10)        MRGBChanAve()                     "Ave"        (0.0->255.0)
     5                32($20)        MRGBChanStdev()                   "Stdev"      (0.0->255.0)
     6                64($40)        MRGBChanInRange()                 "InRng"      (0.0->1.0)
     7               128($80)        MRGBChanPNorm()                   "PNorm"      (0.0->??? depends upon d and u)
  The Channel Postfix is of the form "_0", where 0 is RED, 1 is GREEN and 2 is Blue, 3 is ALPHA(RGB32 ONLY), and is appended to the
  base name described above. So eg MRGBChanMin for RED channel 0 with default Prefix is "MRCS_Min_0".
  MRGBChanstats() allows you to inquire multiple results simultaneously, with not much more overhead than calling a single individual
  routine, however, you should not select sub functions that you dont need as there may be an additional unnecessary overhead.
  The Default flgs=255($FF) are all bits set and so sets ALL global vars at once.
  MRGBChanStats(flgs=1+2+16) would set global vars "MRCS_Min_0", "MRCS_Max_0" and "MRCS_Ave_0" for full frame current_frame, Red Channel.

  In addition to above Global Variables, MRGBChanStats() sets an int Global variable (where default prefix) of "MRCS_PixelCount_0" being
  the number of Red Channel pixels in mask area X,Y,W,H between MaskMin and MaskMax inclusive, or pixels scanned in X,Y,W,H area
  where mask not used.

  NOTE, MRGBChanStats() allows Chan to be -1, where ALL three R, and G, and B channels are processed simultaneouly for ALL functions
   selected by flgs arg (ALPHA Channel is NOT processed).
   A chan arg of -2 (RGB32 ONLY allowed) will additionally process the ALPHA channel as well as R+G+B.
   Also Note, (where default Prefix) MRCS_PixelCount_x is also set (identically) for all channels when Chan == -1 or -2.

#############################################

StainlessS
M53, Script similar to your previous post:
Code:
# Requires RT_Stats v1.23

Avisource("D:\avs\Test.avi")    # Planar

cRGB = ConvertToRGB32()
Mask = Last                     # Use Planar clip Luma as Mask

S = """%d]
 YMax=%d
 rAve=%.1f:%.1f  rMin=%d:%d  rMax=%d:%d  rGood=%.3f
 gAve=%.1f:%.1f  gMin=%d:%d  gMax=%d:%d  gGood=%.3f
 bAve=%.1f:%.1f  bMin=%d:%d  bMax=%d:%d  bGood=%.3f
 AllGood=%f
 Pixels=%d
"""

flgs = 1 + 2 + 16                   # Min + Max + Ave

Channel = -1                        # -1=R+G+B ::: -2=R+G+B(+ALPHA, RGB32 ONLY) ::: or 0 -> 3 == single channel (3 Only for RGB32)

cRGB.ScriptClip("""
    Ymax  = Mask.RT_YPlaneMax()     # Highest Y value in clip
    rAve=MRGBChanAve(Last, mask, Chan=0, MaskMin=Ymax)
    rMin=MRGBChanMin(Last, mask, Chan=0, MaskMin=Ymax)
    rMax=MRGBChanMax(Last, mask, Chan=0, MaskMin=Ymax)
    gAve=MRGBChanAve(Last, mask, Chan=1, MaskMin=Ymax)
    gMin=MRGBChanMin(Last, mask, Chan=1, MaskMin=Ymax)
    gMax=MRGBChanMax(Last, mask, Chan=1, MaskMin=Ymax)
    bAve=MRGBChanAve(Last, mask, Chan=2, MaskMin=Ymax)
    bMin=MRGBChanMin(Last, mask, Chan=2, MaskMin=Ymax)
    bMax=MRGBChanMax(Last, mask, Chan=2, MaskMin=Ymax)
    MRGBChanStats(Last,    mask, Chan=Channel, MaskMin=Ymax,MaskMax=Ymax,flgs=flgs)
    rGood=(MRCS_Max_0==0) ? 1.0 : MRCS_Ave_0/MRCS_Max_0     # Approx 'goodness' of Red channel average (if max==0 then Ave must be 0)
    gGood=(MRCS_Max_1==0) ? 1.0 : MRCS_Ave_1/MRCS_Max_1
    bGood=(MRCS_Max_2==0) ? 1.0 : MRCS_Ave_2/MRCS_Max_2
    AllGood = rGood * gGood * bGood
    RT_Subtitle(S,
        \ current_frame,
        \ Ymax,
        \ rAve,MRCS_Ave_0,rMin,MRCS_Min_0,rMax,MRCS_Max_0,rGood,
        \ gAve,MRCS_Ave_1,gMin,MRCS_Min_1,gMax,MRCS_Max_1,gGood,
        \ bAve,MRCS_Ave_2,bMin,MRCS_Min_2,bMax,MRCS_Max_2,bGood,
        \ AllGood,
        \ MRCS_PixelCount_0
        \ )
    return Last
""")
EDIT: Above, MRGBChanAve/Min/Max individual channel functions not necessary, just to show that multi-functional MRGBChanStats
provides identical results. Below unnecessary individual function calls stripped out:
Code:
# Requires RT_Stats v1.23

Avisource("D:\avs\Test.avi")    # Planar

cRGB = ConvertToRGB32()
Mask = Last                     # Use Planar clip Luma as Mask

S = """%d]
 YMax=%d
 rAve=%.1f  rMin=%d  rMax=%d  rGood=%.2f
 gAve=%.1f  gMin=%d  gMax=%d  gGood=%.2f
 bAve=%.1f  bMin=%d  bMax=%d  bGood=%.2f
 AllGood=%f
 Pixels=%d
"""

flgs = 1 + 2 + 16                   # Min + Max + Ave

Channel = -1                        # -1=R+G+B ::: -2=R+G+B(+ALPHA, RGB32 ONLY) ::: or 0 -> 3 == single channel (3 Only for RGB32)

cRGB.ScriptClip("""
    Ymax  = Mask.RT_YPlaneMax()     # Highest Y value in clip
    MRGBChanStats(Last,    mask, Chan=Channel, MaskMin=Ymax,MaskMax=Ymax,flgs=flgs)
    rGood=(MRCS_Max_0==0) ? 1.0 : MRCS_Ave_0/MRCS_Max_0     # Approx 'goodness' of Red channel average (if max==0 then Ave must be 0)
    gGood=(MRCS_Max_1==0) ? 1.0 : MRCS_Ave_1/MRCS_Max_1
    bGood=(MRCS_Max_2==0) ? 1.0 : MRCS_Ave_2/MRCS_Max_2
    AllGood = rGood * gGood * bGood
    RT_Subtitle(S,
        \ current_frame,
        \ Ymax,
        \ MRCS_Ave_0,MRCS_Min_0,MRCS_Max_0,rGood,
        \ MRCS_Ave_1,MRCS_Min_1,MRCS_Max_1,gGood,
        \ MRCS_Ave_2,MRCS_Min_2,MRCS_Max_2,bGood,
        \ AllGood,
        \ MRCS_PixelCount_0
        \ )
    return Last
""")
__________________
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 2013 at 21:14.
StainlessS is offline   Reply With Quote
Old 10th September 2013, 21:20   #22  |  Link
martin53
Registered User
 
Join Date: Mar 2007
Posts: 407
StainlessS, could you please check:
Code:
ColorBars()
ScriptClip("""  #"
    Try {
        R = MRGBChanMin(last, chan=0)
        R = MRGBChanMax(last, chan=0)
        R = MRGBChanAve(last, chan=0)
        return last
    } catch (err_msg) {
        RT_Debug(err_msg)
    }
""")    #"
[5288] RT_Debug: Script error: there is no function named "MRGBChanAve"
[5288] RT_Debug: ([ScriptClip], line 5)

although .cpp (TAKE2) is 4 seconds older than .dll and reads @line501:
Code:
AVSValue __cdecl MRGBChanAve(AVSValue args, void* user_data, IScriptEnvironment* env) {
	MYLO mylo;
	AVSValue undef;
	//               [9]=chan,threshold,lo,hi,[10]=maskmin,[11]=maskmax,mu,d,p,u
	if(MRGBChanstatsLo(mylo,RTAVE_F,"MRGBChanAve: ",args,env,
			args[9],undef,undef,undef,args[10],args[11],undef,undef,undef,undef)==0)
		return -1;
	return mylo.ddat[RTAVE-RTAVE];
}
martin53 is offline   Reply With Quote
Old 10th September 2013, 22:26   #23  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by StainlessS View Post
EDIT: Oops, somehow MRGBChanAve got squished, and dont work:
Code:
"MRGBChanMin",              "c[mask]c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[threshold]f[Chan]i[MaskMin]i[MaskMax]i"
"MRGBChanMax",              "c[mask]c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[threshold]f[Chan]i[MaskMin]i[MaskMax]i"
"MRGBChanMinMaxDifference", "c[mask]c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[threshold]f[Chan]i[MaskMin]i[MaskMax]i"
"MRGBChanMedian",           "c[mask]c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[Chan]i[MaskMin]i[MaskMax]i"
"MAChanAve",                "c[mask]c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[Chan]i[MaskMin]i[MaskMax]i"
"MRGBChanStdev",            "c[mask]c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[Chan]i[MaskMin]i[MaskMax]i"
"MRGBChanInRange",          "c[mask]c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[Chan]i[lo]i[hi]i[MaskMin]i[MaskMax]i"
"MRGBChanPNorm",            "c[mask]c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[Chan]i[mu]f[d]i[p]i[u]i[MaskMin]i[MaskMax]i"
"MRGBChanStats","c[mask]c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[threshold]f[Chan]i[lo]i[hi]i[flgs]i[prefix]s[MaskMin]i[MaskMax]i[mu]f[d]i[p]i[u]i"
Fixing it it now and adding to MRGBChanStats chan = -1 option, to get R + G + B (NOT ALPHA) channels at once for all flgs functions.
and

Quote:
Originally Posted by StainlessS View Post
M53, find here fix for previous post edit bug, + mods + Docs.

MRgbChanStats() v1.03Beta, Here:
http://www.mediafire.com/download/xx...b_20130908.zip
Post before yours gives fixed dll.

EDIT: The hilited line above tells Avisynth the name of the function and args names and type (although function call removed from above text)
__________________
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; 10th September 2013 at 22:35.
StainlessS is offline   Reply With Quote
Old 11th September 2013, 14:06   #24  |  Link
martin53
Registered User
 
Join Date: Mar 2007
Posts: 407
going to test it tonight.

EDIT: a new issue occurs.
yup's test clip, following script lines
Code:
	MRGBChanStats(cPre, cPre24, x=border, y=border, w=-border, h=-border, Chan=0, flgs=$12, prefix="fRGB_", MaskMin=fY_yMax-1)
	MRGBChanStats(cPre, cPre24, x=border, y=border, w=-border, h=-border, Chan=1, flgs=$12, prefix="fRGB_", MaskMin=fY_yMax-1)
	MRGBChanStats(cPre, cPre24, x=border, y=border, w=-border, h=-border, Chan=2, flgs=$12, prefix="fRGB_", MaskMin=fY_yMax-1)
	if (info>0) { RT_Debug("Rmax Gmax Bmax", string(fRGB_Ave_0, "%23.1f"), string(fRGB_Ave_1, "%6.1f"), string(fRGB_Ave_2, "%6.1f")) }
up to MRGBStats V1.02b, debug output
RT_Debug: Rmax Gmax Bmax 244.7 231.5 204.5
which is credible (clip looks too warm).

Same clip, same script, V1.03b dll
RT_Debug: Rmax Gmax Bmax 204.5 231.5 244.7
R & B seem mixed up

EDIT2: chan=-1 is very helpful! R & B appear same as with single channels.

Last edited by martin53; 11th September 2013 at 16:27.
martin53 is offline   Reply With Quote
Old 11th September 2013, 21:09   #25  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Sorry bout dat m53, dont you just hate little endian.
LINK REMOVED

Find here v1.4b and test avs, and also shown below:
Code:
#MRGBChanStats Tester

AviSource("D:\avs\test.avi")
#Colorbars()
#Blankclip(color=$FFCCAA)

BilinearResize(720,576)

M=ConvertToYV12()
CC=M.ConvertToRGB32()

#M=RT_Undefined()               # Un-Comment for Maskless

S="""
    Name    Separate   StatsChan     Chan-1

    R Min     %4d       %4d        %4d
    G Min     %4d       %4d        %4d
    B Min     %4d       %4d        %4d
    R Max     %4d       %4d        %4d
    G Max     %4d       %4d        %4d
    B Max     %4d       %4d        %4d
    R Dif     %4d       %4d        %4d
    G Dif     %4d       %4d        %4d
    B Dif     %4d       %4d        %4d
    R Med     %4d       %4d        %4d
    G Med     %4d       %4d        %4d
    B Med     %4d       %4d        %4d
    R Ave      %6.2f     %6.2f      %6.2f
    G Ave      %6.2f     %6.2f      %6.2f
    B Ave      %6.2f     %6.2f      %6.2f
    R Std      %6.2f     %6.2f      %6.2f
    G Std      %6.2f     %6.2f      %6.2f
    B Std      %6.2f     %6.2f      %6.2f
    R InR      %6.2f     %6.2f      %6.2f
    G InR      %6.2f     %6.2f      %6.2f
    B InR      %6.2f     %6.2f      %6.2f
    R PNm      %6.2f     %6.2f      %6.2f
    G PNm      %6.2f     %6.2f      %6.2f
    B PNm      %6.2f     %6.2f      %6.2f
    Pixels     ------     %6d      %6d
"""

flgs=$FF    MMin=200 MMax=235  LO= 192 HI=255

NOPIXELS    ="\nNO PIXELS FOUND IN MASK"
CHAN_ONE    ="a_"
CHAN_MULTI  ="b_"

CC.GScriptClip("""
    GSCript("
        C=Last
        rmin=MRGBChanMin(C,M,chan=0,maskmin=MMin,maskmax=MMax)
        if(rmin<0) {
            RT_Subtitle(NOPIXELS)
        } else {
            gmin=MRGBChanMin(C,M,chan=1,maskmin=MMin,maskmax=MMax)
            bmin=MRGBChanMin(C,M,chan=2,maskmin=MMin,maskmax=MMax)
            rmax=MRGBChanMax(C,M,chan=0,maskmin=MMin,maskmax=MMax)
            gmax=MRGBChanMax(C,M,chan=1,maskmin=MMin,maskmax=MMax)
            bmax=MRGBChanMax(C,M,chan=2,maskmin=MMin,maskmax=MMax)
            rdif=MRGBChanMinMaxDifference(C,M,chan=0,maskmin=MMin,maskmax=MMax)
            gdif=MRGBChanMinMaxDifference(C,M,chan=1,maskmin=MMin,maskmax=MMax)
            bdif=MRGBChanMinMaxDifference(C,M,chan=2,maskmin=MMin,maskmax=MMax)
            rmed=MRGBChanMedian(C,M,chan=0,maskmin=MMin,maskmax=MMax)
            gmed=MRGBChanMedian(C,M,chan=1,maskmin=MMin,maskmax=MMax)
            bmed=MRGBChanMedian(C,M,chan=2,maskmin=MMin,maskmax=MMax)
            rave=MRGBChanAve(C,M,chan=0,maskmin=MMin,maskmax=MMax)
            gave=MRGBChanAve(C,M,chan=1,maskmin=MMin,maskmax=MMax)
            bave=MRGBChanAve(C,M,chan=2,maskmin=MMin,maskmax=MMax)
            rstd=MRGBChanStdev(C,M,chan=0,maskmin=MMin,maskmax=MMax)
            gstd=MRGBChanStdev(C,M,chan=1,maskmin=MMin,maskmax=MMax)
            bstd=MRGBChanStdev(C,M,chan=2,maskmin=MMin,maskmax=MMax)
            rinr=MRGBChanInRange(C,M,chan=0,maskmin=MMin,maskmax=MMax,lo=LO,hi=HI)
            ginr=MRGBChanInRange(C,M,chan=1,maskmin=MMin,maskmax=MMax,lo=LO,hi=HI)
            binr=MRGBChanInRange(C,M,chan=2,maskmin=MMin,maskmax=MMax,lo=LO,hi=HI)
            rpnm=MRGBChanPNorm(C,M,chan=0,maskmin=MMin,maskmax=MMax)
            gpnm=MRGBChanPNorm(C,M,chan=1,maskmin=MMin,maskmax=MMax)
            bpnm=MRGBChanPNorm(C,M,chan=2,maskmin=MMin,maskmax=MMax)

            MRGBChanStats(C,M,chan=0, flgs=flgs,maskmin=MMin,maskmax=MMax,prefix=CHAN_ONE,lo=LO,hi=HI)
            MRGBChanStats(C,M,chan=1, flgs=flgs,maskmin=MMin,maskmax=MMax,prefix=CHAN_ONE,lo=LO,hi=HI)
            MRGBChanStats(C,M,chan=2, flgs=flgs,maskmin=MMin,maskmax=MMax,prefix=CHAN_ONE,lo=LO,hi=HI)
            MRGBChanStats(C,M,chan=-1,flgs=flgs,maskmin=MMin,maskmax=MMax,prefix=CHAN_MULTI,lo=LO,hi=HI)
            RT_Subtitle(S,
                \ rmin, a_Min_0,        b_Min_0,
                \ gmin, a_Min_1,        b_Min_1,
                \ bmin, a_Min_2,        b_Min_2,
                \ rmax, a_Max_0,        b_Max_0,
                \ gmax, a_Max_1,        b_Max_1,
                \ bmax, a_Max_2,        b_Max_2,
                \ rdif, a_MinMaxDiff_0, b_MinMaxDiff_0,
                \ gdif, a_MinMaxDiff_1, b_MinMaxDiff_1,
                \ bdif, a_MinMaxDiff_2, b_MinMaxDiff_2,
                \ rmed, a_Med_0,        b_Med_0,
                \ gmed, a_Med_1,        b_Med_1,
                \ bmed, a_Med_2,        b_Med_2,
                \ rave, a_Ave_0,        b_Ave_0,
                \ gave, a_Ave_1,        b_Ave_1,
                \ bave, a_Ave_2,        b_Ave_2,
                \ rstd, a_Stdev_0,      b_Stdev_0,
                \ gstd, a_Stdev_1,      b_Stdev_1,
                \ bstd, a_Stdev_2,      b_Stdev_2,
                \ rinr, a_InRng_0,      b_InRng_0,
                \ ginr, a_InRng_1,      b_InRng_1,
                \ binr, a_InRng_2,      b_InRng_2,
                \ rpnm, a_PNorm_0,      b_PNorm_0,
                \ gpnm, a_PNorm_1,      b_PNorm_1,
                \ bpnm, a_PNorm_2,      b_PNorm_2,
                \ a_PixelCount_0,       b_PixelCount_0
            \ )
        }
    ")
    return Last
""")

return Last
EDITED: Moved pixel count into correct columns.
__________________
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; 25th September 2013 at 19:48.
StainlessS is offline   Reply With Quote
Old 15th September 2013, 20:14   #26  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
MYStats v1.05beta. New version see 1st post.

v1.05b, Added YUY2 and RGB24/32. Added Matrix arg for RGB. Sped up.

Added several test scripts.

Here results of a test timer:-
Code:
00000005    1.48367798      RT_Debug: MYStats And RT_Stats Comparison Test Timer
00000006    1.48369825      RT_Debug: Timing 24x5(120) runs on 2500 Frames (Total Frames=300000)
00000007    1.82623863      RT_Debug: RT_YankChain       0.068Secs :36945.81FPS :: Basic GetFrame() [ADJUSTMENT]
00000008    17.67099571     RT_Debug: YPlaneMin          3.167Secs :  789.47FPS :: ADJUSTED 3.099Secs  806.71FPS
00000009    28.43142319     RT_Debug: RT_YPlaneMin       2.156Secs : 1159.38FPS :: ADJUSTED 2.089Secs 1196.94FPS
00000010    38.60767746     RT_Debug: MYPlaneMin         2.031Secs : 1230.72FPS :: ADJUSTED 1.964Secs 1273.13FPS
00000011    54.49916077     RT_Debug: YPlaneMax          3.177Secs :  786.91FPS :: ADJUSTED 3.109Secs  804.03FPS
00000012    65.30001068     RT_Debug: RT_YPlaneMax       2.156Secs : 1159.55FPS :: ADJUSTED 2.088Secs 1197.13FPS
00000013    75.47039795     RT_Debug: MYPlaneMax         2.031Secs : 1230.92FPS :: ADJUSTED 1.963Secs 1273.34FPS
00000014    92.12580872     RT_Debug: YPlaneMinMaxDif    3.328Secs :  751.20FPS :: ADJUSTED 3.260Secs  766.79FPS
00000015    102.99511719    RT_Debug: RT_YPlaneMinMaxDif 2.172Secs : 1151.01FPS :: ADJUSTED 2.104Secs 1188.02FPS
00000016    113.16596222    RT_Debug: MYPlnMnMxDiff      2.031Secs : 1230.92FPS :: ADJUSTED 1.963Secs 1273.35FPS
00000017    128.98162842    RT_Debug: YPlaneMedian       3.162Secs :  790.72FPS :: ADJUSTED 3.094Secs  808.02FPS
00000018    139.77700806    RT_Debug: RT_YPlaneMedian    2.156Secs : 1159.55FPS :: ADJUSTED 2.088Secs 1197.12FPS
00000019    149.93418884    RT_Debug: MYPlaneMedian      2.031Secs : 1230.72FPS :: ADJUSTED 1.964Secs 1273.13FPS
00000020    156.48509216    RT_Debug: AverageLuma        1.307Secs : 1912.78FPS :: ADJUSTED 1.239Secs 2017.22FPS
00000021    160.90562439    RT_Debug: RT_AverageLuma     0.880Secs : 2840.91FPS :: ADJUSTED 0.812Secs 3077.56FPS
00000022    163.33396912    RT_Debug: MAverageLuma       0.484Secs : 5161.72FPS :: ADJUSTED 0.417Secs 5999.98FPS
00000023    174.12857056    RT_Debug: RT_YPlaneStdev     2.156Secs : 1159.55FPS :: ADJUSTED 2.088Secs 1197.12FPS
00000024    184.28181458    RT_Debug: MYPlaneStdev       2.031Secs : 1230.92FPS :: ADJUSTED 1.963Secs 1273.34FPS
00000025    195.05416870    RT_Debug: RT_YInRange        2.156Secs : 1159.55FPS :: ADJUSTED 2.088Secs 1197.12FPS
00000026    205.19453430    RT_Debug: MYInRange          2.031Secs : 1230.92FPS :: ADJUSTED 1.963Secs 1273.35FPS
00000027    276.00216675    RT_Debug: Avisynth_ALL      14.157Secs :  176.60FPS :: ADJUSTED14.089Secs  177.44FPS
00000028    286.96133423    RT_Debug: RT_Avisynth_ALL    2.187Secs : 1142.95FPS :: ADJUSTED 2.120Secs 1179.43FPS
00000029    298.01794434    RT_Debug: RT_ALL             2.213Secs : 1129.52FPS :: ADJUSTED 2.146Secs 1165.14FPS
00000030    308.51885986    RT_Debug: MYStats_ALL        2.099Secs : 1191.04FPS :: ADJUSTED 2.031Secs 1230.72FPS
00000031    308.51953125    RT_Debug: Total Runtime =   5.12 Mins
RT_ALL contains a couple of funcs not available in built-in runtime funcs.
MYStats_ALL contains an additional func not yet available in RT_Stats.

Will at some point integrate MYStats and RGBChanStats into RT_Stats. Above timings done on Maskless MYStats colorbars YV12 clip.

EDIT: Above Avisynth built-in funcs produce a lot better results with a nearly empty plugins directory,
presume loaded plugins appears earlier in function list, so are accessed quicker.
__________________
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; 25th September 2013 at 19:51.
StainlessS is offline   Reply With Quote
Old 25th September 2013, 19:52   #27  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
MyStats + MRgbChanStats Combo v1.06, perhaps final version. See 1st and 2nd posts.

v1.06, added MRgbChanStats.

Will soon be integrated into RT_Stats.
__________________
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 ???
StainlessS is offline   Reply With Quote
Reply

Tags
averageluma, mask, rt_stats

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:16.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.