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. |
21st January 2021, 04:22 | #1 | Link |
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++.
|
21st January 2021, 21:46 | #4 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,829
|
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. 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. |
22nd January 2021, 03:46 | #6 | Link |
Useful n00b
Join Date: Jul 2014
Posts: 1,667
|
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.
|
22nd January 2021, 13:47 | #7 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Metric=1, defo seems better than default metric=0.
EDIT: Quote:
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. |
|
22nd January 2021, 14:54 | #8 | Link |
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 |
22nd January 2021, 21:17 | #10 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
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. 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. |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|