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. |
1st March 2011, 21:53 | #1 | Link |
Registered User
Join Date: Nov 2003
Location: Austria
Posts: 75
|
Median multiple captures of the same video (VHS)
Is there a filter like average(clip1,0.25,clip2,0.25,clip3,0.25,clip4,0.25) see here:
http://forum.doom9.org/showthread.ph...19#post1129919 that does perform median instead of average? I want to use it to remove random spikes from vhs captures. The median filter would discard the extreme values (spikes) that is only present in one of the clips in time. I've found threads here that talk about median (clip1, clip2, clip3...) but regarding an actual filter I only found the average filter that performs average instead of median). |
1st March 2011, 22:28 | #2 | Link |
Registered User
Join Date: Nov 2004
Location: Spain
Posts: 408
|
Median is generally referred to an odd number of clip:
Read this two thread: http://forum.doom9.org/showthread.ph...90#post1169990 http://forum.doom9.org/showthread.ph...76#post1331776 Good luck |
2nd March 2011, 00:20 | #4 | Link |
Registered User
Join Date: Jan 2006
Posts: 1,867
|
Code:
Function Median1(clip input_1, clip input_2, clip input_3, string "chroma") {# median of 3 clips from Helpers.avs by G-force chroma = Default(chroma,"process") #default is "process". Alternates: "copy first" or "copy second" Interleave(input_1,input_2,input_3) chroma == "process" ? Clense(reduceflicker=false) : Clense(reduceflicker=false,grey=true) SelectEvery(3,1) chroma == "copy first" ? last.MergeChroma(input_1) : chroma == "copy second" ? last.MergeChroma(input_2) : last Return(last) } |
6th March 2011, 19:28 | #5 | Link |
Registered User
Join Date: Nov 2003
Location: Austria
Posts: 75
|
Been using the median of multiple captures with success. I also successfully used average.
http://forum.doom9.org/showthread.php?t=100626 While average reduces random playback noise, median can eliminate random spikes (white lines and the likes) present in one capture but not the other. So now I was thinking about a combination that can do both. That would be a median of an even amount of captures with a minimum of 4 captures of the same video. First median calculates the two values closest to the middle and then an average is applied to these two values. Such a filter/script could eliminate spikes and reduce random playback noise form VHS captures. Anyone here got a clue how to do this? |
6th March 2011, 19:48 | #6 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
Basically, Median filter is not possible / not well-defined for an even number of elements.
However, the median of MaskTools:mt_lutf() iirc works this way - cut the outliers & average the remainder. *.mp4guy once told me about this behaviour. If so, the following maybe does what you want: Code:
clip1 = ... ... clip4 = ... c13 = interleave(clip1,clip3).assumefieldbased.assumetff.weave c24 = interleave(clip2,clip4).assumefieldbased.assumetff.weave c1234 = interleave(c13,c24).assumefieldbased.assumetff.weave mt_lutf(c1234,c1234,mode="median",pixels="0 0 0 1 0 2 0 3",expr="y",U=3,V=3) pointresize(c1.width,c1.height) Similar can be done for 8 elements quite easily. A bit different for 6 elements - absolutely possible, but more difficult to fiddle together. In any case: mt_lutf("median") is quite slow ... be prepared for sluggish speeds. Another possibility: use 4 or 5 captures, create 3 different simple medians of 3 elements via clense (which is very fast), then average the medians.
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
8th March 2011, 20:04 | #7 | Link |
Registered User
Join Date: Nov 2003
Location: Austria
Posts: 75
|
Thanks for your response Didée!
Finally I had time to test this. Downloaded masktools-v2.0a48.zip (seems to be the latest) VirtualDub shows an error: Script error: mt_lutf does not have a named argument "pixels" The mt_lutf description says: clip clip1, clip clip2, string mode("avg"), string expr("y"), string yexpr("y", string uexpr("y"), string vexpr("y") and mt_luts: clip clip1, clip clip2, string mode("avg"), string pixels(""), string expr("x"), string yexpr("x"), string uexpr("x"), string vexpr("x") whereas mt_lutf does have "median" but mt_luts not. Further my source is YUY2. Not sure if masktools will work with this color space. I also tried this (median_average4.avs) - seems to work and it is relatively fast (~19 fps) Code:
clip1=AVISource("D:\cap1.avi") clip2=AVISource("D:\cap2.avi") clip3=AVISource("D:\cap3.avi") clip4=AVISource("D:\cap4.avi") M1=Median1(clip1,clip2,clip3) M2=Median1(clip2,clip3,clip4) M3=Median1(clip1,clip3,clip4) M4=Median1(clip1,clip2,clip4) Average(M1, 0.25, M2, 0.25, M3, 0.25, M4, 0.25) Function Median1(clip input_1, clip input_2, clip input_3, string "chroma") {# median of 3 clips from Helpers.avs by G-force chroma = default(chroma,"process") #default is "process". Alternates: "copy first" or "copy second" Interleave(input_1,input_2,input_3) chroma == "process" ? Clense(reduceflicker=false) : Clense(reduceflicker=false,grey=true) SelectEvery(3,1) chroma == "copy first" ? last.MergeChroma(input_1) : chroma == "copy second" ? last.MergeChroma(input_2) : last Return(last) } Took the function of a post AVIL pointed me to. Also I'm interested in how the clense median works in this function. Is it by sub pixel / pixel? Does it compare/median the values of each sub pixel eg. pixel 1 of clip1 has sub pixel values of YUV 20/5/60; clip2 21/4/62; clip3 250/253/252. Sub pixel median would be 21/5/62. Is this actual the case or is the result 21/4/62 pixel median or even something else? Did compare the result of the above script with an individual capture (via subtract) and in general it is an improvement, but there can be some rare cases where some frames of an individual capture can be better eg. at the start of a recording where the player searches the best tracking one of the individual captures can be better than the median. Did dig out a ~25 year old recording. Actually the remaining part of a recording because I did copy over some newer stuff on most part of the tape. Here's an example of one frame that's considerable enhancement with median+averaging multiple recordings (completely unfiltered). Frame of one single capture: above script (4 captures): |
8th March 2011, 20:33 | #8 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
Oops, yes. I meant to write mt_lutS, not mt_lutF. Sorry for the confusion. Also, I'm pretty sure mt_lutS does have the "median" operator, since I've used it numerous times. Is it not in the documentation?
Clense does what you call "sub pixel" filtering. All three planes - Y, U and V - are processed independently. MaskTools does support YUY2 ... with a trick. You need "SSE2Tools" by kassandro. Then IIRC it goes like YUY2_clip ConvertInterleavedToPlanar() MaskToolsFilter() ConvertPlanarToInterleaved() *fallen asleep*
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
11th March 2011, 19:17 | #9 | Link |
Registered User
Join Date: Nov 2003
Location: Austria
Posts: 75
|
Thanks again Didée!
Been searching quite a while to find the SSE2Tools. They are no longer inside the RemoveGrain zip/rar files hosted on kassandros site. Anyway found the dll in some package: Code:
File Size SSE2Tools.dll 30.720 SSE3Tools.dll 49.664 SSETools.dll 28.672 SSEToolsS.dll 69.632 Tried all of them one by one but I always get: mt_luts : unsupported color space. masktools only supports planar YUV colorspaces (YV12, YV15, YV24) Code:
clip1=AVISource("D:\cap1.avi") clip2=AVISource("D:\cap2.avi") clip3=AVISource("D:\cap3.avi") clip4=AVISource("D:\cap4.avi") c13 = interleave(clip1,clip3).assumefieldbased.assumetff.weave c24 = interleave(clip2,clip4).assumefieldbased.assumetff.weave c1234 = interleaved2planar(interleave(c13,c24).assumefieldbased.assumetff.weave) planar2interleaved(mt_lutS(c1234,c1234,mode="median",pixels="0 0 0 1 0 2 0 3",expr="y",U=3,V=3)) pointresize(clip1.width,clip1.height) 1) error in the script 2) wrong version of sse2tools 3) wrong version of masktools File / size mt_masktools-26.dll 966.656 31.12.2010 Last edited by BBugsBunny; 12th March 2011 at 18:36. |
12th March 2011, 18:40 | #11 | Link |
Registered User
Join Date: Nov 2003
Location: Austria
Posts: 75
|
Solved the problem by replacing mt_masktools-26.dll with mt_masktools-25.dll
No idea what's the difference between the two and why it works with one but not the other, but it works and that is of most importance. |
12th March 2011, 19:07 | #12 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,374
|
Quote:
"25" is for avisynth 2.5.x |
|
13th March 2011, 21:49 | #13 | Link | |
Registered User
Join Date: Nov 2003
Location: Austria
Posts: 75
|
poisondeathray, thanks for clearing me up!
Did compare Didée script with the one I posted earlier (with the sample screen) and it seems as they are doing exactly the same (compared them with substract) only that the script I posted is much faster then Didée's. In fact the script I posted is based on Didée's idea posted earlier: Quote:
|
|
19th March 2011, 23:21 | #15 | Link | |
Registered User
Join Date: Nov 2003
Location: Austria
Posts: 75
|
Quote:
But I do have some other recordings that are worth it. BTW the screencap is from transformers that aired ~in the mid 80'. The interlacing (field blending?) of this recording is also badly messed up. The recording is 25fps but it seems as if they took a 29.97 fps source (or 24 fps ->29.97?) and converted it to pal. Just out of curiosity I played a bit with RestoreFPS but I could get no good result. Not sure what the original fps was and how they messed it up. Not sure if there's a way to correct this and how to do it. But this stuff is only some testing anyway. |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|