View Full Version : Filter bad VHS cartoon with temporal blending, noisy chroma, other garbage...?
ChiDragon
12th May 2013, 08:59
http://102.imagebam.com/download/nlsiu9180q6r2ItUfRlL7Q/25414/254136763/gobots-ick.jpg
Sample links: http://www.embedupload.com/?d=7SYWLGYSIL
http://www.crocko.com/F4C49FEEF7DA454F948E26C5CBB1EFD9/
http://wh4plc.1fichier.com/
http://uptobox.com/1mc2uvvmon3t
http://hipfile.com/i0d3xe0yi20n
http://www8.zippyshare.com/v/36285215/file.html
http://filerio.in/8q5hcfa27stm
This was captured via S-Video from a pro S-VHS deck, so the chroma issues are on the tape and not a comb filter problem.
Chainmax
12th May 2013, 15:10
Is this a PAL or NTSC video? Also, could you step through about 10 consecutive frames and tell us which of those 10 frames are "correct" and which show blending?
ChiDragon
13th May 2013, 08:12
The tape is NTSC and I detelecined it with the DoubleWeave().Pulldown() method.
I'm not sure what you mean as there are no good frames as far as I can tell. Everything is smeared.
creaothceann
14th May 2013, 21:16
The tape is NTSC and I detelecined it with the DoubleWeave().Pulldown() method.
Please upload an untouched sample to MediaFire. It's faster and much more comfortable than most of the sites listed above.
Afaik there are better inverse teleciners, e.g. the AnimeIVTC package. A filter like Checkmate(tthr2=0) has to be applied before though.
ChiDragon
15th May 2013, 06:11
There is no better IVTC than a perfect manual inverse of the original cadence (which is what I did (http://avisynth.org/mediawiki/ShowFiveVersions)). That's useless for modern anime but this is an American show so the pattern is consistent.
Here it is with the pulldown intact: http://www.mediafire.com/?5q7vn0zrygv94o8
creaothceann
15th May 2013, 16:21
Well, you can clean it up a bit with TemporalDegrain.
Show(v2, v3)
function v1 {
# the first file that was posted
DSS2("deinterlaced.avi").AssumeFPS(30000, 1001)
FinalCrop
}
function v2 {
# the second file that was posted (original sample)
DSS2("interlaced.avi").AssumeFPS(30000, 1001)
DoubleWeave
a = Pulldown(0, 2)
b = Pulldown(0, 3)
Interleave(a, b)
TemporalDegrain
SelectEven
FinalCrop
}
function v3 {
DSS2("interlaced.avi").AssumeFPS(30000, 1001)
Checkmate(tthr2=0)
AnimeIVTC(mode=1, ifade=true, precision=3, killcomb=1)
TemporalDegrain
Masked_DHA
FinalCrop
}
function FinalCrop(clip c) {c.Crop(10, 2, -10, -2)} # ...then get 4:3 via Avisynth filters / x264 SAR values / MKV aspect ratio setting
function Show(clip a, clip b, string "text_a", string "text_b") {
text_a = default(text_a, "")
text_b = default(text_b, "")
a = a.ConvertToRGB32
b = b.ConvertToRGB32
c = Subtract(a, b)
x = a.Width / 2
y = a.Height / 2
a1 = a.Crop(0, 0, 0, -y).Crop(1, 1, -1, -1).AddBorders(1, 1, +1, +1, $FF0000).Subtitle(text_a, text_color=$FFFFFF)
a2 = a.Crop(0, +y, 0, 0).Crop(1, 1, -1, -1).AddBorders(1, 1, +1, +1, $0000FF)
b1 = b.Crop(0, 0, 0, -y).Crop(1, 1, -1, -1).AddBorders(1, 1, +1, +1, $FF0000).Subtitle(text_b, text_color=$FFFFFF)
b2 = b.Crop(0, +y, 0, 0).Crop(1, 1, -1, -1).AddBorders(1, 1, +1, +1, $0000FF)
c1 = c.Crop(0, 0, 0, -y).Crop(1, 1, -1, -1).AddBorders(1, 1, +1, +1, $FF0000).Subtitle("top" , text_color=$FFFFFF, halo_color=$FF0000)
c2 = c.Crop(0, +y, 0, 0).Crop(1, 1, -1, -1).AddBorders(1, 1, +1, +1, $0000FF).Subtitle("bottom", text_color=$FFFFFF, halo_color=$0000FF)
a = StackVertical (a1, a2)
b = StackVertical (b1, b2)
c = StackHorizontal(c1, c2)
StackVertical(StackHorizontal(a, b), c)
}
I think the biggest problem is that the chroma/luma data has been temporarily shifted.
ChiDragon
31st May 2013, 20:20
Thanks for the suggestions and sorry I took so long to reply. I tried to find out how to install all of the prereqs for AnimeIVTC and came up empty. I have the 7z extracted but if the next step is to manually load every single plugin, I don't have the patience.
I like the result of your "v2" example but with Checkmate added. I think I might also add a vertical chroma blur since there are streaks in it if I view them with UtoY/VtoY.
Checkmate(tthr2=0)
Interleave(DoubleWeave().Pulldown(0,2),DoubleWeave().Pulldown(0,3))
ConvertToYV12(interlaced=false)
TemporalDegrain
SelectEven
Sadly I didn't see a reduction in the halos even with DeHalo_alpha_mt, so I didn't bother trying Masked_DHA. Maybe some magic parameters would make it recognize such wide ones, but I don't know how to tune this filter.
lisztfr9
31st May 2013, 23:28
You could try exorcist or another one, there aren't much... maybe in VD there is also one.
L
ChiDragon
1st June 2013, 04:34
How does one differentiate spatial ghosting from halos? Directionality?
creaothceann
1st June 2013, 10:02
I tried to find out how to install all of the prereqs for AnimeIVTC and came up empty. I have the 7z extracted but if the next step is to manually load every single plugin, I don't have the patience.
Avisynth has a "plugins" directory where you put most of Avisynth's filters (a few might need to be put into SYSTEM32/SYSWOW64, but iirc those in the requirements package don't need that).
I never load DLLs in my scripts.
ChiDragon
1st June 2013, 17:48
Yeah, but it doesn't load them from all of the subdirectories inside the plugins dir.
creaothceann
1st June 2013, 18:52
Why would you need subdirectories there?
My Avisynth directory looks like this:
Docs
Examples
Extras
FilterSDK
License Translations
plugins
plugins - C
plugins - old
plugins - packages
The "packages" directory is where I extract all the ZIP/RAR/... archives into when I download them off doom9 / the plugin author's website. So there's also an "Avisynth\plugins - packages\AnimeIVTC\requirements\" in there. These files are just for reference; they're not used directly.
The "C" directory contains DLLs that are loaded via LoadCPlugin. For example there's Yadif.avsi which consists of a single LoadCPlugin("..\plugins - C\Yadif.dll") call.
ChiDragon
1st June 2013, 19:12
Let me start again. I have this 7z of AnimeIVTC requirements extracted to \plugins\AnimeIVTC and it seems that I would have to go through every subdirectory of that folder copying and pasting the DLL files into my plugins dir for them to be autoloaded.
creaothceann
1st June 2013, 19:57
Yes. (Or put an .avsi script into "plugins" that loads them all, though it'd be more work.) But you could do a search (with Windows or a nice tool like Total Commander (http://www.google.com/search?tbm=isch&q=%22Total+Commander%22)) to search for every DLL (Total Commander: Alt+F7), then copy&paste them.
Note that there's mt_masktools-25.dll and mt_masktools-26.dll; iirc you only have to install #25 for Avisynth 2.5 and #26 for Avisynth 2.6. ReduceFlicker, RemoveGrain, Repair and RSharpen have different DLLs suitable for what SSE level your CPU has (find out with CPU-Z or similar tools). And Yadif needs the LoadCPlugin call.
EDIT: AvsRecursion might need to be put into System32/SysWOW64, but maybe a directory that is in your %PATH% environment variable is enough...
ChiDragon
1st June 2013, 20:52
But you could do a search then copy&paste them.
Shoot. Good idea.
Unfortunately I'm running into a script error:
I don't know what "sfthr" means
(AnimeIVTC 2.00.avsi, line 151)
Does AnimeIVTC actually perform the kind of restoration functions I'm looking for? I've already got the IVTC part done perfectly.
creaothceann
1st June 2013, 21:53
Unfortunately I'm running into a script error:
This should be the fixed version: http://pastebin.com/3deFWsaq
They talk about the error in the thread; unfortunately it's not fixed in the readily-accessible places.
This is what I hate about Avisynth: It's no complete package. You have to hunt down DLLs all over the internet, there are incompatibilities and 'versionitis' and missing documentation everywhere, plugins work in the 'flawed' YV12 colorspace by default, you may very well have to mix 'bleeding-edge' plugins with ones that are ten years old, there are many plugins for common tasks and you have to test each one and tweak its parameters to find a 'working set', half the script links on the external filters (http://avisynth.org/mediawiki/External_filters) page point to a short forum post by Didée...
Ideally the developers would "take ownership" of the algorithms: providing a central hosting place, making sure all (sensible) colorspaces are supported, make sure that documentation is provided. Sort of like Mozilla's Firefox extensions repository, and like a codec pack (k-Lite, CCCP) in that incompatibilities are fixed so that Avisynth feels more like a 'product' and not something where every plugin is a wall of a labyrinth.
Does AnimeIVTC actually perform the kind of restoration functions I'm looking for? I've already got the IVTC part done perfectly.
I wouldn't be so sure about it. An IVTC can never be 'truly perfect' by definition because ideally we would have the original film that the animation was shot onto. Even if you have a DVD image instead of VHS you still have to fight bad transfers, the low resolution, and the MPEG2 compression. As for your question, I got very nice results with my Figure 17 DVDs, better than I'd have gotten if I had to do it manually (although at some point I had to admit defeat and settle for a video that "looks good" instead of "preserves the DVD material" because the DVDs are flawed, and I had to shoot for a sensible file size too). Look into the documentation and do some tests.
osgZach
2nd June 2013, 09:46
Ideally the developers would "take ownership" of the algorithms: providing a central hosting place, making sure all (sensible) colorspaces are supported, make sure that documentation is provided. Sort of like Mozilla's Firefox extensions repository, and like a codec pack (k-Lite, CCCP) in that incompatibilities are fixed so that Avisynth feels more like a 'product' and not something where every plugin is a wall of a labyrinth.
.
That's been one of my loterry wet dreams for a while. Set a few million aside, get some committed developers and try and clean up / standardize / modernize everything..
who wants to buy me lottery tickets? :D
That's my take on the "do it yourself if you want it done" mantra. If you can't do it yourself, pay someone to do it for you.
ChiDragon
3rd June 2013, 06:32
All Ghostbuster (http://forum.doom9.org/showthread.php?t=35339) succeeded in doing was adding/subtracting an additional offset copy of the image, creating additional ghosts rather than removing any. Again I'm not so sure it is ghosting or halos or echoes or reflections or who-knows.
And as for the other issue with the video, I take it trying to undo a temporal blend is just impossible?
ChiDragon
3rd June 2013, 08:27
I'm working from intermediate files created from the previous script that I posted.
Interleave(last,dfttest().Spline36Resize(270,480).nnedi2_rpow2(rfactor=4,cshift="lanczosresize",fwidth=720,fheight=480).Subtitle("Filter"))
Is there some way I can use a mask to retain the original edge resolution (which in some scenes exceeds 360px) while exploiting the averaged texture information?
Intermediate & Filtered:
Ghitulescu
3rd June 2013, 08:35
http://102.imagebam.com/download/nlsiu9180q6r2ItUfRlL7Q/25414/254136763/gobots-ick.jpgThis was captured via S-Video from a pro S-VHS deck, so the chroma issues are on the tape and not a comb filter problem.
But they might have been introduced during the original recording, but this of no relevance now.
There is no better IVTC than a perfect manual inverse of the original cadence (which is what I did (http://avisynth.org/mediawiki/ShowFiveVersions)). That's useless for modern anime but this is an American show so the pattern is consistent.
It doesn't matter.
From the image you posted I assume is one Japanese anime. Your logic resides on that the American television had the original "progressive" material and provided the copy with a regular pattern. I doubt this is the case - I think they simply aired the NTSC copy they received from Japanese. No studio is so stupid to spend man-hours in improving the quality of a material nobody else cares - in the best case they ran the material through a norm verifier to be sure it fulfils the federal regulations.
Bottom line - I think you need to do the deinterlacing by hand.
ChiDragon
4th June 2013, 00:34
But they might have been introduced during the original recording, but this of no relevance now.
It's a prerecorded tape, and that is what I meant.
From the image you posted I assume is one Japanese anime.
Why are you assuming this when I already said that it's an American cartoon?
Bottom line - I think you need to do the deinterlacing by hand.
??? I did!
creaothceann
4th June 2013, 06:07
It may have been produced in the US (http://en.wikipedia.org/wiki/Gobots), but how would the technique be different from anime?
ChiDragon
4th June 2013, 07:00
It wouldn't be for a show that old.
Ghitulescu
4th June 2013, 08:31
Why are you assuming this when I already said that it's an American cartoon?
You said it's an American Show not an American cartoon. I understood, my bad, that this was aired on American television, not that was an American production. Telecined American cartoons are quite predictable, you're right.
lisztfr9
4th June 2013, 12:10
How does one differentiate spatial ghosting from halos? Directionality?
I think halo concerns mostly (sharp) edges, while in your sample image also color is shifted (see the fushia zone).
L
lordsmurf
29th October 2013, 02:55
Is that Gobots? :cool:
I believe it's been fully release by WB now.
ChiDragon
29th October 2013, 18:26
Hmm, not that I can find. Still just the "The Original Mini-Series" (first 5 eps) MOD release.
*.mp4 guy
1st November 2013, 21:02
A few years ago someone posted a similarly bad vhs transfer, and I took a stab at fixing it. Luckily that script works on your source without any modifications. Unluckily, it is a very complex script with a lot of dependencies. AFAIK, it's the the only thing going that really "works" for this sort of thing, but whether it is actually worth using instead of just blurring everything is harder to say.
http://i.imgur.com/jvadNZa.png (http://imgur.com/jvadNZa)
http://i.imgur.com/M7hvuep.png (http://imgur.com/M7hvuep)
Tofusensei
2nd November 2013, 09:30
A few years ago someone posted a similarly bad vhs transfer, and I took a stab at fixing it. Luckily that script works on your source without any modifications. Unluckily, it is a very complex script with a lot of dependencies.
Mind posting the script and dependencies? I'm working with a similar source. Thanks!
*.mp4 guy
3rd November 2013, 06:40
My main reluctance in posting the script, is that it is essentially a wall of badly organized untunable "back magic".
plugins:
masktools 2
awarpsharp
removegrain package
medianblur
xsharpen
variable blur
average
(and quite possibly others)
script functions:
ReCon
removecrap3C2
Twarp
Halomask1
halomask2
YAHR
MinBlur
NLLV_Variant4, NLLH_Variant4
Tblur4
NLHV, NLHH
BlurV, blurH
TNLHV, TNLHH
(and quite possibly others)
used script:
FIR = mt_convolution(horizontal="-1 0 -3 -6 0 -16 64 -24 128 -24 64 -16 0 -6 -3 0 -1 ", vertical=" 1 ", u=2, v=2)
FIR_DIFF = mt_makediff(FIR, last)
THR=string(1000)
Median = MT_Luts(FIR_DIFF, FIR_DIFF, mode="med", pixels = " 0 0 1 0 -1 0 2 0 -2 0 " , expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1)
ReconstructedMedian = mt_makediff(FIR_DIFF, Median)
out = mt_makediff(FIR, ReconstructedMedian)
FIR_DIFF = mt_makediff(FIR, out)
THR=string(200)
Median = MT_Luts(FIR_DIFF, FIR_DIFF, mode="med", pixels = " 0 0 1 0 -1 0 2 0 -2 0 " , expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1)
ReconstructedMedian = mt_makediff(FIR_DIFF, Median)
out = mt_makediff(FIR, ReconstructedMedian)
out
#mt_convolution(horizontal=" 64 0 128 0 64", vertical=" 1 ", u=2, v=2)
dx=320
dy=320
dx2=640
dy2=480
threshh=16
threshv=16
lanczosresize(dx*2, dy*2, taps=7)
MV = Mt_LutXY(last.mt_convolution(horizontal=" 1 ", vertical=" 4 0 -10 0 42 -14 -14 168 -14 -14 42 0 -10 0 4 ", u=1, v=1), last, " X Y - Abs 64 * ", U=-128, V=-128)
Mt_Merge(mt_convolution(horizontal=" 1 ", vertical=" 4 0 -10 0 42 -14 -14 772 -14 -14 42 0 -10 0 4 ", u=3, v=3), last.TNLHV(threshv).TNLHV(threshv), MV)
MH = Mt_LutXY(last.mt_convolution(horizontal=" 4 0 -10 0 42 -14 -14 168 -14 -14 42 0 -10 0 4 ", vertical=" 1 ", u=1, v=1), last, " X Y - Abs 64 * ", U=-128, V=-128)
Mt_Merge(mt_convolution(horizontal=" 4 0 -10 0 42 -14 -14 772 -14 -14 42 0 -10 0 4 ", vertical=" 1 ", u=3, v=3), last.TNLHH(threshh).TNLHH(threshh).tblur4(16), MH)
lanczosresize(dx2*2, dy2*2, taps=7)
pointresize(width/2, height/2)
Recon(strv=0.5, radv=1, lmode=0, radh=2, strh=3)
twarp(112)
removecrap3c2(112)
Dependencies: Pastebin (because formatting) (http://pastebin.com/BdDTfqek)
Tofusensei
4th November 2013, 07:59
Thanks for posting that! After some wrangling, I got the script to work. Is it supposed to be super-slow? I was getting well under 0.1 fps.
Anyway, it did not work as planned but made some pretty cool results. Thanks for the fun experiment, anyway!
http://i.imgur.com/G68dcYr.jpg
*.mp4 guy
5th November 2013, 08:30
I try not to post anything that is /completely/ unusable. Even on an older machine, the script should be at least 10 times faster than that.
As far as the error goes, that is not one of the possible failure modes of the script. I've seen issues with avisynth versions newer than 2.58, it could also conceivably be an issue with versions of various plugins. If you care to try to get it working, and using avisynth 2.58 doesn't work, I would look at masktools, removegrain and variable blur.
ChiDragon
26th July 2015, 19:19
Hmm, not that I can find. Still just the "The Original Mini-Series" (first 5 eps) MOD release.
As of March 10, this VHS tape is now fit for the recycle bin. Warner Archive's completed the GoBots TV eps with a final MOD release. They're actually remastered from the film elements, too.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.