Log in

View Full Version : FredAverage v0.03, Jan 15 2019


StainlessS
14th April 2017, 00:31
FredAverage(), by StainlessS @ Doom9
Requires VS2008 CPP runtimes.

Prompted by this post here:- https://forum.doom9.org/showthread.php?p=1803528#post1803528

dll's for avs v2.58 + avs v2.60/+ x86 & x64.

A simple average filter for Avisynth standard colorspaces, only.
Returns a clip where each return frame is a single color average of input frame, same size and colorspace as input.
Does an invert on result if Bool Invert==true.


FredAverage, (not to be confused with RedAverage):- https://forum.doom9.org/showthread.php?t=174520
Requires VS2008 CPP runtimes.

dll's for avs v2.58 & avs v2.60/+ x86 & x64.

A simple average filter for Avisynth v2.60 standard colorspaces, only. (v2.58 colorspaces for v2.58 dll)

Returns a clip where each return frame is a single color average of input frame, same size and colorspace as input.
Does an invert on result if Bool Invert==true.


ColorSpace, YV12, YV16, YV24, YV411, Y8, YUY2, RGB24, RGB32, only.

Return clip Y, U and V, or R, G and B, will be channel averages, unless Invert==True, where channels averages will be inverted.

FredAverage(clip c, Bool "Invert"=false,Bool "TV_YUV"=False)

Invert, Default false == sampled average. Otherwise Inverted average.
TV_YUV, Default false, If True(And YUV), then photo negative invert around TV levels mid Y(125.5), rather than 127.5.

Returns clip same colorspace and size as input.

StainlessS.


FredAverageTest.avs

# WHEN YUV, RHS IMAGE, outer = Average : Left Inner = PC Levels Invert : Inner Right = TV Levels Invert

AviSource("D:\Parade.avi")
Crop(0,0,Width/8*8,Height/8*8)
ConvertToYV12
ORG=LAst
AVE=ORG.FredAverage
I_PC=ORG.FredAverage(Invert=true,TV_YUV=False).BilinearResize(ORG.Width/4,ORG.Height/2)
I_TV=ORG.FredAverage(Invert=true,TV_YUV=true ).BilinearResize(ORG.Width/4,ORG.Height/2)
I=Stackhorizontal(I_PC,I_TV)
AVE=AVE.Overlay(I,x=ORG.Width/4,y=ORG.height/4)
StackHorizontal(ORG,AVE)

https://i.postimg.cc/QFHyKz6k/Fredaverage-Test.jpg (https://postimg.cc/QFHyKz6k)

See MediaFire link in sig below this post.

Zip includes v2.58 + avs v2.60/+ x86 & x64 dll's, + Source + full VS2008 project files for easy rebuild. (~76KB)

GMJCZP
14th April 2017, 02:33
Thank you TinMan for your efforts.

I'm somewhat outdated with the latest developments, but I know you've got your hand in regard to color correction in old videos. :thanks:

StainlessS
14th April 2017, 09:03
GMJCZP, you are welcome, we aim to please. :)

Sign displayed in some UK gents urinals.
We aim to please, would you aim too please.

Magik Mark
21st April 2017, 22:48
Is it possible to have 64bit version?


Sent from my iPhone using Tapatalk

StainlessS
15th January 2019, 23:17
FredAverage v0.02, new version see first post.

Moved to VS2008, Added Version resource + x64.
Added arg TV_YUV, default false.


FredAverage(clip c, Bool "Invert"=false,Bool "TV_YUV"=False)

Invert, Default false == sampled average. Otherwise Inverted average.
TV_YUV, Default false, If True, then photo negative invert around TV levels mid Y(125.5), rather than 127.5.

StainlessS
16th January 2019, 16:54
FredAverage v0.03, new version see first post.

Bugfix version.

v0.01, First release. 2.60 only.
v0.02, 15 Jan 2019. Moved to VS2008, Added Version Resource + v2.58 + x64.
Added bool arg TV_YUV;
v0.03, 15 Jan 2019. BugFix version, fixed TV_YUV rounding.


BUGFIX in BLUE, + 0.5 was missing

int ave;
double ave_D = double(acc) / samples; // Luma Ave
int aveU = int(double(accU) / samplesUV + 0.5); // U ave
int aveV = int(double(accV) / samplesUV + 0.5); // V ave

if(invert) { // invert ?
if(tvy) {
ave = int(-(ave_D - 125.5) + 125.5 + 0.5); // TV_YUV Y mid = 125.5, invert, and Round
} else {
ave = int(ave_D + 0.5) ^ 0xFF; // PC_YUV Y mid = 127.5, symmetrical about 127.5
}
aveU ^= 0xFF;
aveV ^= 0xFF;
} else {
ave = int(ave_D + 0.5);
}
ave = max( min( ave, 255) ,0);

StainlessS
5th April 2021, 03:44
FredAverge v0.04Beta, new Beta version.
See Mediafire or sendSpace below this post.
or here:- [ FredAverage_25&26_x86_x64_dll_v0.04Beta_20210405.zip ]:- https://www.mediafire.com/file/5n8wt219aro4gxb/FredAverage_25%252626_x86_x64_dll_v0.04Beta_20210405.zip/file


FredAverage, (not to be confused with RedAverage):- https://forum.doom9.org/showthread.php?t=174520
Requires VS2008 CPP runtimes.

dll's for avs v2.58 & avs v2.60/+ x86 & x64.

A simple average filter for Avisynth v2.60 standard colorspaces, only. (v2.58 colorspaces for v2.58 dll)

Returns a clip where each return frame is a single color average of input frame, same size and colorspace as input.
Does an invert on result if Bool Invert==true.

ColorSpace, YV12, YV16, YV24, YV411, Y8, YUY2, RGB24, RGB32, only.

Return clip Y, U and V, or R, G and B, will be channel averages, unless Invert==True, where channels averages will be inverted.

FredAverage(clip c, Bool "Invert"=false,Bool "TV_YUV"=False,clip "Mask"=Undefined)

c, Avs v2.60 std 8 bit colorspaces only [v2.58 colorspaces when v2.58 dll]. Further limits if mask supplied.
Invert, Default false == sampled average. Otherwise Inverted average.
TV_YUV, Default false, If True(And YUV), then photo negative invert around TV levels mid Y(125.5), rather than 127.5.
Mask, Default Undefined.
If Mask Supplied,
Source clip c cannot be subsampled, ie YV24 or Y8 or RGB24 or RGB32, ONLY.
Mask must be same size as source clip c, and must be 8 bit planar with Y [only Y used].
Where Mask Y value is 128 or more, then corresponding pixel from clip c is included in the average,
where 127 or less, corresponding pixel from clip c is ignored.
Mask can be single frame affecting all frames of source clip c, or same length as clip c
with potentially different mask for each source frame. [Final mask frame will be used if shorter than c clip].

Returns clip same colorspace and size as input.

StainlessS.


FredAverage_MaskTest.avs in AVS folder

FN = "D:\Parade.avi" # Some Clip [bigger than about 320x320, not too long]
BLOCK_AVE=False # True Show Average of BLOCK, False Show average of NON BLOCK [UnComment RETURN ORG to show RED block overlay]
CONVRGB24 = True # True convert Source To RGB24 : Else convert To YV24
###############
X=32
Y=32
W=256
H=256
###
AviSource(FN)
(CONVRGB24) ? ConvertToRGB24 : ConvertToYv24
RED=Last.BlankClip(Length=1,color=$FF0000)
WHITE=Last.BlankClip(Length=1,color=$FFFFFF)
BLACK=Last.BlankClip(Length=1,color=$000000)
WHITE.Loop(100)+Last+BLACK.Loop(100) # White 100 frames + Clip + Black 100 Frames
Last.OVERLAY(RED.crop(0,0,W,H),x=X,y=Y)
ORG=Last
#RETURN ORG # SHOW Clip with BLOCK if UNCOMMENT
##############
M=Last.BlankClip(Length=1,width=W,height=H,color=$FFFFFF)
M=M.AddBorders(X,Y,Width-X-W,Height-Y-H,$000000).ConvertToYV12
#return M

M = (BLOCK_AVE) ? M : M.Invert

FredAverage(Last,Mask=M)
Subtitle(BLOCK_AVE?"BLOCK - AVERAGE":"NOT BLOCK - AVERAGE")
StackHORIZONTAL(ORG,Last)
return last


Need some testing, I gotta get some sleep.

EDIT: RHS, is average of the NOT red block on LHS.
https://i.postimg.cc/Tw5DHSKN/Fred-Average-Mask-Test-00.jpg (https://postimages.org/)