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.

 Doom9's Forum Average n of x (TooT style)
 User Name Remember Me? Password
 Register FAQ Calendar Search Today's Posts Mark Forums Read

 Thread Tools Search this Thread Display Modes
 11th July 2017, 05:03 #1  |  Link juhok Registered User     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.
 11th July 2017, 06:42 #2  |  Link WolframRhodium Registered User   Join Date: Jan 2016 Posts: 105 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.
11th July 2017, 11:43   #3  |  Link
Myrsloik
Professional Code Monkey

Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,932
Quote:
 Originally Posted by WolframRhodium 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

11th July 2017, 12:37   #4  |  Link
WolframRhodium
Registered User

Join Date: Jan 2016
Posts: 105
Quote:
 Originally Posted by Myrsloik 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.

 11th July 2017, 13:43 #5  |  Link juhok Registered User     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.
11th July 2017, 14:44   #6  |  Link
WolframRhodium
Registered User

Join Date: Jan 2016
Posts: 105
Quote:
 Originally Posted by juhok 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.

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements and Chat     General Discussion     News     Forum / Site Suggestions & Help General     Decrypting     Newbies     DVD2AVI / DGIndex     Audio encoding     Subtitles     Linux, Mac OS X, & Co Capturing and Editing Video     Avisynth Usage     Avisynth Development     VapourSynth     Capturing Video     DV     HDTV / DVB / TiVo     NLE - Non Linear Editing     VirtualDub, VDubMod & AviDemux     New and alternative a/v containers Video Encoding     (Auto) Gordian Knot     MPEG-4 ASP     MPEG-4 Encoder GUIs     MPEG-4 AVC / H.264     High Efficiency Video Coding (HEVC)     New and alternative video codecs     MPEG-2 Encoding (HD) DVD, Blu-ray & (S)VCD     One click suites for DVD backup and DVD creation     DVD Rebuilder     (HD) DVD & Blu-ray authoring     Advanced authoring     IFO/VOB Editors     DVD burning Hardware & Software     Software players     Hardware players     PC Hard & Software Programming and Hacking     Development     Translations

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

 Doom9.org - Archive - Top

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