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 > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 11th July 2017, 05:03   #1  |  Link
juhok
Registered User
 
juhok's Avatar
 
Join Date: Dec 2005
Posts: 110
Average n of x (TooT style)

The goal: average VHS/etc captures. To get rid of semi random errors caused by analog crappiness.

I've tried:
Code:
video = core.misc.AverageFrames([video1, video2, video3, video4, video5], [1,1,1,1,1])

It's decent. But 2/3 ("TooT for Avisynth") or 3/5 or some other weight would be better. No idea how to do it tho.
juhok is offline   Reply With Quote
Old 11th July 2017, 06:42   #2  |  Link
WolframRhodium
Registered User
 
Join Date: Jan 2016
Posts: 162
I guess the "TooT or Avisynth" works the same way as the following code according to E-Male's thread:

Code:
def toot(clipa, clipb, clipc):
    absXYMinus = 'x y - abs'
    absXZMinus = 'x z - abs'
    absYZMinus = 'y z - abs'
    xyAverage = 'x y + 2 /'
    xzAverage = 'x z + 2 /'
    yzAverage = 'y z + 2 /'
    expr = '{0} {1} < {0} {2} < {3} {5} ? {1} {2} < {4} {5} ? ?'.format(absXYMinus, absXZMinus, absYZMinus, xyAverage, xzAverage, yzAverage)

    return core.std.Expr([clipa, clipb, clipc], [expr])
Above code is so ugly, though

Last edited by WolframRhodium; 11th July 2017 at 12:46.
WolframRhodium is offline   Reply With Quote
Old 11th July 2017, 11:43   #3  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by WolframRhodium View Post
I guess the "TooT or Avisynth" works the same way as the following code according to E-Male's thread:

Code:
def toot(clipa, clipb, clipc):
    absXYMinus = 'x y - abs'
    absXZMinus = 'x z - abs'
    absYZMinus = 'y z - abs'
    xyAverage = 'x y + 2 /'
    xzAverage = 'x z + 2 /'
    yzAverage = 'y z + 2 /'
    expr = '{0} {1} < {0} {2} < {3} {5} ? {1} {2} < {4} {5} ? ?'.format(absXYMinus, absXZMinus, absYZMinus, xyAverage, xzAverage, yzAverage)

    return core.std.Expr([clipa, cilpb, clipc], [expr])
Above code is so ugly, though
That's creative. Maybe you could throw something together using makediff and merge that may or may not be faster. Probably not though.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 11th July 2017, 12:37   #4  |  Link
WolframRhodium
Registered User
 
Join Date: Jan 2016
Posts: 162
Quote:
Originally Posted by Myrsloik View Post
That's creative. Maybe you could throw something together using makediff and merge that may or may not be faster. Probably not though.
The limited range of an integer format clip is sometimes annoying.

e.g:
Code:
diff = MakeDiff(a, b)
a_ = MergeDiff(b, diff)
"a_" is not the same as "a" when there's an overflow:
If a=1, b=254, then diff=0 due to the clipping, so a_=126, not equal to a.

One way I know to solve that is the following:
Code:
diff = MakeDiff(a, b)
b_tmp = MakeDiff(a, diff)
a_ = MergeDiff(b_tmp, diff)
Now, if a=1, b=254, then diff=0, and b_tmp=129, so a_=1==a


As for TooT, overflow can affect the decision of which two clips should be averaged, so I do not use MakeDiff.

But sure, there's no problem with Merge, so the code can be:
Code:
def toot(clipa, clipb, clipc):
    absXYMinus = 'x y - abs'
    absXZMinus = 'x z - abs'
    absYZMinus = 'y z - abs'
    xyAvg = core.std.Merge(clipa, clipb)
    xzAvg = core.std.Merge(clipa, clipc)
    yzAvg = core.std.Merge(clipb, clipc)
    expr = '{0} {1} < {0} {2} < a c ? {1} {2} < b c ? ?'.format(absXYMinus, absXZMinus, absYZMinus)

    return core.std.Expr([clipa, clipb, clipc, xyAvg, xzAvg, yzAvg], [expr])

Last edited by WolframRhodium; 11th July 2017 at 12:46.
WolframRhodium is offline   Reply With Quote
Old 11th July 2017, 13:43   #5  |  Link
juhok
Registered User
 
juhok's Avatar
 
Join Date: Dec 2005
Posts: 110
Thanks a bunch. Can this same principle be expanded to 3 of 5? Seems like there's some very stubborn chroma glitches which fool 2 of 3.
juhok is offline   Reply With Quote
Old 11th July 2017, 14:44   #6  |  Link
WolframRhodium
Registered User
 
Join Date: Jan 2016
Posts: 162
Quote:
Originally Posted by juhok View Post
Thanks a bunch. Can this same principle be expanded to 3 of 5? Seems like there's some very stubborn chroma glitches which fool 2 of 3.
Sorry I can't do that.
The code will be very long for 3 of 5 when using ternary operator to implement argmin as above. Even for 2 of 5, 2^4=16 operators are required, I think. I'm too lazy to do it, (and I usually make mistakes on such large programs).

Last edited by WolframRhodium; 11th July 2017 at 14:47.
WolframRhodium is offline   Reply With Quote
Reply

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 14:34.


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