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 21st January 2021, 04:22   #1  |  Link
Ceppo
Registered User
 
Join Date: Feb 2016
Location: Nonsense land
Posts: 339
What's the math beyond TIVTC comb detection?

Could someone please explain to me what's the math/idea beyond TIVTC comb detection? I tried looking into the source code but is confusing since it's very long and I'm new to C++.
Ceppo is offline   Reply With Quote
Old 21st January 2021, 04:37   #2  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
I assume you've looked at Tritical's posts in the original TVITC thread:

TDeint and TIVTC
johnmeyer is offline   Reply With Quote
Old 21st January 2021, 20:05   #3  |  Link
Ceppo
Registered User
 
Join Date: Feb 2016
Location: Nonsense land
Posts: 339
I was specifically interested in isCombedTIVTC() since it does just that, and I didn't find any specific post there.
Ceppo is offline   Reply With Quote
Old 21st January 2021, 21:46   #4  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
This is what the TFM help file says:

Code:
Assume 5 neighbouring pixels (a,b,c,d,e) positioned vertically.

   a
   b
   c
   d
   e

metric=0

d1 = c - b;
d2 = c - d;
if ((d1 > cthresh && d2 > cthresh) || (d1 < -cthresh && d2 < -cthresh))
{
   if (abs(a+4*c+e-3*(b+d)) > cthresh*6) it's combed;
}

metric=1

val = (b - c) * (d - c);
if (val > cthresh*cthresh) it's combed;

Metric 0 is what tfm used previous to v0.9.12.0.  Metric 1 is the combing metric used
in Donald Graft's FieldDeinterlace()/IsCombed() funtions in decomb.dll.
In case you're interested and haven't seen it, there's some info on MeGUI's source detection here.
http://avisynth.nl/index.php/Interlace_detection
From memory it's how AutoGK did it too.

Last edited by hello_hello; 22nd January 2021 at 11:23.
hello_hello is offline   Reply With Quote
Old 21st January 2021, 22:59   #5  |  Link
Ceppo
Registered User
 
Join Date: Feb 2016
Location: Nonsense land
Posts: 339
Completely missed, thank you!
Ceppo is offline   Reply With Quote
Old 22nd January 2021, 03:46   #6  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
Quote:
Originally Posted by hello_hello View Post
Metric 1 is the combing metric used
in Donald Graft's FieldDeinterlace()/IsCombed() funtions in decomb.dll.
Good stuff, hello_hello. That code was partially inspired by Gunnar Thalin's AreaDeinterlace code. I wrote some extensive journal posts about interlace detection. Tomorrow I will put those back online and link them here for you Ceppo. It's a very interesting theoretical problem.
videoh is offline   Reply With Quote
Old 22nd January 2021, 13:47   #7  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Metric=1, defo seems better than default metric=0.

EDIT:
Quote:
val = (b - c) * (d - c);
If signs [(b-c) and (d-c)] are opposite, then its a gradient and val = -ve (or 0), and no combing [b >= c >= d, OR b <= c <= d]
If signs are same then its no gradient and val = +ve, and possible combing [c < b && c < d, OR c > b && c > d].

Something like that.

Could also use something like val = - ((b - c) * (c - d)) which might be less confusing. [b, c and d are ordered in the expression]
EDIT: Where when signs [b-c and c-d] are same is gradient, and where opposite is possible combing.
Where opposite signs then val = +ve, and magnitude of val decides if combed when compared with cthresh. EDIT: Actually cthresh*cthresh.
__________________
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; 22nd January 2021 at 23:04.
StainlessS is offline   Reply With Quote
Old 22nd January 2021, 14:54   #8  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
http://rationalqm.us/journal/journal2003.html

The following entries are relevant to interlace detection:

5-26-2003
6-6-2003
6-14-2003
6-18-2003
6-21-2003
videoh is offline   Reply With Quote
Old 22nd January 2021, 19:28   #9  |  Link
Ceppo
Registered User
 
Join Date: Feb 2016
Location: Nonsense land
Posts: 339
Thank you guys for the help!
Ceppo is offline   Reply With Quote
Old 22nd January 2021, 21:17   #10  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
val = (b - c) * (d - c)
If signs [(b-c) and (d-c)] are opposite, then its a gradient and val = -ve (or 0), and no combing [b >= c >= d, OR b <= c <= d]
If signs are same then its no gradient and val = +ve, and possible combing [c < b && c < d, OR c > b && c > d].

Something like that.
Above method 1 seems a bit "off".
Code:
What if eg b=101, c=100, d=137, cthresh=6.

b   = 101
c   = 100
d   = 137
b-c = 101-100 = 1
d-c = 137-100 = 37
val = 1 * 37  = 37

IsCombed = val > (cthresh*cthresh) : 37 > 6*6(36) : true ie combed

b is only 1 above c, but because d is so much above c is considered combed. maybe is not ideal as it is 'almost a gradient' (could be  noise pixel).

I suggest that maybe should also be a requirement that below should be true.

# Prep
CTHSQR  = cthresh*cthresh
CD2     = Round(Max(cthresh,1) / 2.0)  # CD2 minimum 1 type int  # EDIT: See last EDIT

IsCombed = (val > CTHSQR) && (Abs(b-c) >=CD2) && (Abs(d-c) >= CD2) # Extra requirement, not computed unless 1st part succeeds

So abs(b-c) would have to be at least 3, or b = 103 to detect c=100 IsCombed.

Might avoid some false IsCombed pixel detections [and therefore some false isCombed Frame detections].
EDIT: cthresh would more likely be in region of 8 (cthresh*cthesh=64) or more.
But above is in the DG realm

EDIT: Above re-written, I thought cthresh was already squared, but comparison should have been on cthresh*chtresh, FIXED.
EDIT: And "gradient" is probably the wrong word in above code block.

EDIT: I kinda like CD2 = Round(Sqrt(Max(cthresh,1)))
Code:
cthresh   CTHSQR  CD2  Practical_values_for_Method1_cthresh
0         0       1
1         1       1
2         4       1
3         9       2
4         16      2
5         25      2   
6         36      2     *
7         49      3     **
8         64      3     ***
9         81      3     ***
10        100     3     ***
11        121     3     ***
12        144     3     ***
13        169     4     **
14        196     4     *
15        225     4
16        256     4
etc
__________________
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; 23rd January 2021 at 02:13.
StainlessS is offline   Reply With Quote
Old 23rd January 2021, 08:17   #11  |  Link
Ceppo
Registered User
 
Join Date: Feb 2016
Location: Nonsense land
Posts: 339
I think that the case you exposed might be fixed by a noise threshold that sets to zero low difference and thus makes null the multiplication.
Ceppo 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 12:06.


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