Mini-Me
21st January 2011, 14:49
I have a peculiar issue with about 100 hours of VHS footage from the same camera: Within each interlaced field, the even lines are slightly brighter than the odd lines, or vice versa. (If I weave the fields into a frame, I see two bright lines followed by two dark lines, etc.) This introduces an odd "scanline" texture into the image. It initially looked like a static noise pattern, but it turns out it's literally a levels issue between odd and even lines of each field (I guess the camera used two recording heads or something?). If the top field has bright even lines and dark odd lines, the bottom field will have bright odd lines and dark even lines.
After studying the histograms for each odd/even subfield in my first test scene, I was able to almost completely eliminate the artifact by reducing gamma to 0.98 on the bright lines with SmoothLevels. (I should note that the approach works 100%, and the "almost" is because I didn't take the time for more precise histogram matching :p). The problem is that the polarity of the artifact changes from scene to scene, so blindly applying the same fix will make things twice as bad half the time. Also, it seems as though the required adjustment might change from scene to scene too.
So, the good news is that adjusting levels on a subfield basis provides a nice solution without blurring the crap out of the video (or blurring it at all actually). The bad news is a fully robust and automatic solution requires independently matching histograms between the odd/even subfields of every...single...field. I checked out filters like HistogramAdjust and ColourLike, but they compute clip-wide histograms and match the entire clip to the same histogram. I could use them, but that would require literally splitting my videos into hundreds of thousands of 1-field clips, matching histograms between odd and even subfields, and reassembling the result. I tried this with Avisynth recursion, but Avisynth obviously choked on such ridiculous recursion levels. ;)
So, what are my options? Would Gavino's Gscript help with iterating through frame-by-frame without choking, or is that a dead end too? Are there any clever ways of making frame-by-frame decisions within the Avisynth scripting language (to at least determine the polarity of each frame), or am I pretty much stuck writing a full-blown plugin to handle this? (I guess the upside of that is that I can borrow histogram-matching code and then use SmoothCurves to actually do the adjustments...)
After studying the histograms for each odd/even subfield in my first test scene, I was able to almost completely eliminate the artifact by reducing gamma to 0.98 on the bright lines with SmoothLevels. (I should note that the approach works 100%, and the "almost" is because I didn't take the time for more precise histogram matching :p). The problem is that the polarity of the artifact changes from scene to scene, so blindly applying the same fix will make things twice as bad half the time. Also, it seems as though the required adjustment might change from scene to scene too.
So, the good news is that adjusting levels on a subfield basis provides a nice solution without blurring the crap out of the video (or blurring it at all actually). The bad news is a fully robust and automatic solution requires independently matching histograms between the odd/even subfields of every...single...field. I checked out filters like HistogramAdjust and ColourLike, but they compute clip-wide histograms and match the entire clip to the same histogram. I could use them, but that would require literally splitting my videos into hundreds of thousands of 1-field clips, matching histograms between odd and even subfields, and reassembling the result. I tried this with Avisynth recursion, but Avisynth obviously choked on such ridiculous recursion levels. ;)
So, what are my options? Would Gavino's Gscript help with iterating through frame-by-frame without choking, or is that a dead end too? Are there any clever ways of making frame-by-frame decisions within the Avisynth scripting language (to at least determine the polarity of each frame), or am I pretty much stuck writing a full-blown plugin to handle this? (I guess the upside of that is that I can borrow histogram-matching code and then use SmoothCurves to actually do the adjustments...)