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
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th April 2017, 00:31   #1  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
FredAverage v0.03, Jan 15 2019

FredAverage(), by StainlessS @ Doom9
Requires VS2008 CPP runtimes.

Prompted by this post here:- https://forum.doom9.org/showthread.p...28#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.

Code:
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
Code:
# 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)


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)
__________________
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; 16th January 2019 at 16:43. Reason: Update
StainlessS is offline   Reply With Quote
Old 14th April 2017, 02:33   #2  |  Link
GMJCZP
Registered User
 
GMJCZP's Avatar
 
Join Date: Apr 2010
Location: I have a statue in Hakodate, Japan
Posts: 744
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.
__________________
By law and justice!

GMJCZP's Arsenal
GMJCZP is offline   Reply With Quote
Old 14th April 2017, 09:03   #3  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
GMJCZP, you are welcome, we aim to please.

Sign displayed in some UK gents urinals.
Quote:
We aim to please, would you aim too please.
__________________
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
Old 21st April 2017, 22:48   #4  |  Link
Magik Mark
Registered User
 
Join Date: Dec 2014
Posts: 666
Is it possible to have 64bit version?


Sent from my iPhone using Tapatalk
__________________
Asus ProArt Z790 - 13th Gen Intel i9 - RTX 3080 - DDR5 64GB Predator - LG OLED C9 - Yamaha A3030 - Windows 11 x64 - PotPlayerr - Lav - MadVR
Magik Mark is offline   Reply With Quote
Old 15th January 2019, 23:17   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
FredAverage v0.02, new version see first post.

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

Code:
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.
__________________
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
Old 16th January 2019, 16:54   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
FredAverage v0.03, new version see first post.

Bugfix version.
Code:
	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
Code:
        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);
__________________
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
Old 5th April 2021, 03:44   #7  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
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/5n8wt...10405.zip/file

Code:
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
Code:
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.
__________________
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; 5th April 2021 at 03:51.
StainlessS is offline   Reply With Quote
Reply

Tags
average


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 21:02.


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