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 23rd May 2010, 09:04   #1  |  Link
kypec
User of free A/V tools
 
kypec's Avatar
 
Join Date: Jul 2006
Location: SK
Posts: 826
How to denoise/despot old cartoon footage?

I've an TV capture from late 80's encoded with Xvid as AVI.
Here is a short sample:
http://www.mediafire.com/file/gtzldnmdxjg/sample.avi
I don't know how to get rid of all that spots, tried MCTemporalDenoise like this:
Code:
# Initialize variable with path to my A/V tools
avdir=GetSystemEnv("PROGRAMFILES")+"\AVTools\"
# Load all the plugins that will be used in the script
Import(avdir + "plugins\MCTemporalDenoise.v1.4.16.avsi") # MCTemporalDenoise (v1.4.16)
LoadPlugin(avdir + "plugins\mvtools2.dll")               # MVTools (v2.5.10)
LoadPlugin(avdir + "plugins\mt_masktools-25.dll")        # Masktools (v2.0a42)
Import(avdir + "plugins\LSFmod.v1.9.avsi")               # LSFmod (v1.9)
LoadPlugin(avdir + "plugins\FFT3DFilter.dll")            # FFT3Dfilter (v2.1.1)
LoadPlugin(avdir + "plugins\TTempSmooth.dll")            # TTempsmooth (v0.9.4)
LoadPlugin(avdir + "plugins\RemoveGrainSSE2.dll")        # Removegrain (v1.0PR)
LoadPlugin(avdir + "plugins\RepairSSE2.dll")             # Repair (v1.0PR)
# Deblock (v1.2)
# Deblock_QED (18.aug.2008)
# DctFilter (v0.0.1.4)
LoadPlugin(avdir + "plugins\EEDI2.dll")                  # EEDI2 (v0.9.2)
LoadPlugin(avdir + "plugins\SangNom.dll")                # Sangnom (v1.0beta)
Import(avdir + "plugins\GradFun2DBmod.v1.5.avsi")        # GradFun2DBmod (v1.5)
LoadPlugin(avdir + "plugins\gradfun2db.dll")             # Gradfun2db (v1.0)
LoadPlugin(avdir + "plugins\AddGrainC.dll")              # AddgrainC (v1.4)

# Open source video clip
AVISource("D:\SOURCE\sample.avi",audio=false)
untouched=last
MCTemporalDenoise(settings="high")
StackHorizontal(untouched,last)
It removed some of the tiny dark spots and smoothed large uniformly coloured areas of picture quite nicely but...most of the bigger spots are still there!
Is there any filter available which would erase that kind of noise?
I'd noticed that all spots occur just in one frame so I think it could be fairly easy to somehow remove them going by temporal approach, or am I thinking wrong?
All other filters that I've tried (UnDot, DeGrainMedian, DeSpot) enable to tune mostly spatial parameters like sizes, thresholds, distances with use of motion compensation but I couldn't get satisfactory results with any of them.
Please advice
kypec is offline   Reply With Quote
Old 24th May 2010, 00:32   #2  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
[bump after thread re-opened]
Guest is offline   Reply With Quote
Old 25th May 2010, 10:08   #3  |  Link
kypec
User of free A/V tools
 
kypec's Avatar
 
Join Date: Jul 2006
Location: SK
Posts: 826
Wow, more than 170 views and not a single reply Is my source really that bad that no one is able to come with at least a suggestion?
kypec is offline   Reply With Quote
Old 25th May 2010, 11:24   #4  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: UK
Posts: 1,673
MVDegrainMulti?

This is just a guess - not sure it's ideal as a "just remove what's different in one frame only" filter, but it's not bad.

Cheers,
David.
2Bdecided is offline   Reply With Quote
Old 25th May 2010, 11:45   #5  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
The task of spot removal has not been solved yet. The name of the game is "choose your poison" : There are lots of possibilities to try, but still, there is no solution. You can only choose between different compromises:

a) Less spot removal with only little damage to original content,
-or-
b) more spot removal with more damage to original content.

Choose your poison.

I could write you a survey about the plentitude of different problems ... would take me two hours, take up two/three/four pages of text, and at the end the conclusion still would be the same: "no solution, only compromises. Choose your poison."


Quick headlines:

- no motion compensation: weak approach, in motion areas it's either ineffective or dangerous

- with motion compensation: theoretically much better, but ... the spots will mislead the motion engine upon deciding if a compensation is "good" or "bad". The larger the spots, the bigger the problem.

- Temporal averaging: in theory it's the "wrong" approach. A spot will get averaged into clean neighbor frames. Also a spot will not be removed, just cut-down in intensity. To be effective, it needs LOTS of temporal neighbors to consider, which in turn is a problem in other aspects.

- temporal median: in theory the "method of choice" for spot removal - does clean removal of spots, no spreading into neighbor frames, needs only a small temporal neighborhood. However, IF something goes wrong (from the side of MVTools in the first place), then it will produce artifacts more worse than those of temporal averaging.
__________________
- 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!)
Didée is offline   Reply With Quote
Old 25th May 2010, 11:56   #6  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
has anyone some experience with:
http://spotremoverfilter.com/
Terka is offline   Reply With Quote
Old 25th May 2010, 12:00   #7  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
Me not. But if it has to be despite all problems, then a deeper look into kassandro's RemoveDirt is worthwile, and recommended.
__________________
- 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!)
Didée is offline   Reply With Quote
Old 25th May 2010, 12:11   #8  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
many of the frames are duplicate, could this be somehow useful?
Terka is offline   Reply With Quote
Old 25th May 2010, 12:30   #9  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
Dunno ... the dup's might help to some extend, but they're not frequent enough that you could rely on them.

For what it's worth, here is a possible primitive for spot removal:

Code:
AviSource("D:\sample_spotty.avi")              

o=last ox=o.width() oy=o.height()

osup = o.MSuper(pel=2,sharp=2)
bv1  = osup.MAnalyse(isb=true, delta=1,blksize=8,overlap=4,search=4)
fv1  = osup.MAnalyse(isb=false,delta=1,blksize=8,overlap=4,search=4) 
bc1  = o.MCompensate(osup,bv1)
fc1  = o.MCompensate(osup,fv1)

Interleave(fc1,o,bc1)
MedianblurT(0,0,0,1)   #  you can also use "Clense(reduceflicker=false)" instead
SelectEvery(3,1)

StackHorizontal(o,last)
__________________
- 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!)
Didée is offline   Reply With Quote
Old 2nd June 2010, 20:40   #10  |  Link
kypec
User of free A/V tools
 
kypec's Avatar
 
Join Date: Jul 2006
Location: SK
Posts: 826
Thank you very much Didée, your approach did wonders to my source. I had to replace MedianBlurT with Clense (hopefully you mentioned that as well) because the encoding process kept crashing at the very end. First I thought that it's x264 latest revision to blame (r1613) but the error persisted even with r1538. Once I found the offending part in this filter chain and replaced it the encoding finished always fine.
Here is my complete script, I tried to smooth big uniformly coloured areas (sky, water surface) even more with FFT3DFilter but didn't see any effect really so in the end I left it out completely.
Code:
# Open source video clip
AVISource("D:\SOURCE\Family-Ness\Rodina Nessovcov.avi",audio=false).Trim(0,7599)
# Initialize variable with path to my A/V tools
avdir=GetSystemEnv("PROGRAMFILES")+"\AVTools\"
# Load all the plugins that will be used in the script
LoadPlugin(avdir + "plugins\mvtools2.dll")         # MVTools (v2.5.10)
#~ LoadPlugin(avdir + "plugins\FFT3DFilter.dll")      # FFT3Dfilter (v2.1.1)
LoadPlugin(avdir + "plugins\aWarpSharp.dll")       # aWarpSharp (2009.06.19)
#~ LoadPlugin(avdir + "plugins\medianblur.dll")       # MedianBlur (v0.84)
LoadPlugin(avdir + "plugins\DePan.dll")            # DePan (v1.10.1)
LoadPlugin(avdir + "plugins\DePanEstimate.dll")    # DePanEstimate (v1.9.2)
LoadPlugin(avdir + "plugins\RepairSSE2.dll")       # Repair (v1.0PR)
LoadPlugin(avdir + "plugins\RemoveGrainSSE2.dll")  # RemoveGrain (v1.0PR)
LoadPlugin(avdir + "plugins\RemoveGrainTSSE2.dll") # RemoveGrainT (v1.0PR)
Import(avdir + "plugins\Stab.avsi")                # Stabilize script (v1.0)

# remove single-frame spots
o=last
osup = o.MSuper(pel=2,sharp=2)
bv1  = osup.MAnalyse(isb=true, delta=1,blksize=8,overlap=4,search=4)
fv1  = osup.MAnalyse(isb=false,delta=1,blksize=8,overlap=4,search=4) 
bc1  = o.MCompensate(osup,bv1)
fc1  = o.MCompensate(osup,fv1)
Interleave(fc1,o,bc1)
#~ MedianblurT(0,0,0,1)   #  you can also use "Clense(reduceflicker=false)" instead
Clense()
SelectEvery(3,1)
# stabilize subtle shaking of whole image
Stab(8,10,10)
# crop and resize
Crop(8,2,-0,-0).Spline36Resize(640,480)
#~ FFT3DFilter(plane=3, bt=3, sigma=3, bw=16, bh=16, ow=8, oh=8) # denoise chroma
aWarpSharp2(thresh=160, blur=3, type=0, depth=16, chroma=4) # sharpen the image, make it crisp and less blurry
#~ StackHorizontal(o,last)
The resulting MP4 (AVC+AAC-HE) is only 41% size of original AVI (ASP+MP3) with better visual quality, isn't that simply amazing?
kypec is offline   Reply With Quote
Old 2nd June 2010, 20:51   #11  |  Link
kypec
User of free A/V tools
 
kypec's Avatar
 
Join Date: Jul 2006
Location: SK
Posts: 826
Quote:
Originally Posted by Terka View Post
has anyone some experience with:
http://spotremoverfilter.com/
I've downloaded and tried that in VDub. I couldn't see anything useful in the output preview. Nothing for the first hundred frames and some debug mode later on with lots of orange and red rectangles, triangles running all over the frame. Only then I realized this is a payware with trial version being awfully crippled I guess.
Author's example screens looked promising though
kypec is offline   Reply With Quote
Old 22nd July 2017, 17:55   #12  |  Link
GMJCZP
Registered User
 
GMJCZP's Avatar
 
Join Date: Apr 2010
Location: I have a statue in Hakodate, Japan
Posts: 744
KillerSpots

I have made Didée's idea to remove spots:

Code:
# Function KillerSpots 3.1
# For primitive videos (live action/animation)
# Function for spot removal
# Original idea by Didée (https://forum.doom9.org/showthread.php?p=1402690#post1402690)
# Developed by GMJCZP
# With adaptation of johnmeyer's revision of RemoveDirt function
# (See RemoveDirt documentation and Film restoration script by videoFred)
# Requirements: MVTools, RGTools, RemoveDirt

Function KillerSpots(clip o, int "limit", bool "advanced",bool "anim", int "repmode", bool "comp")
{
advanced = Default(advanced, true) # best performance, otherwise is the original Didée's idea (for live action is better)
comp     = Default(comp, false) # for compare results

# Options for advanced = true:

limit    = Default(limit, 10) # spot removal limit. Higher values, more killing spots but can hurt details
anim     = Default(anim, true) # for animated content, otherwise is live action
repmode  = Default(repmode, 2) # repair mode for preserve details: repmode=1 for classic Repair, repmode=2 for temporal repair
           # Temporal repair is more safe (limit values can be more highs) but more spots can reappear

Assert((repmode == 1 || repmode == 2), "repmode error, values of 1 or 2 are only admitted")

# Didée's idea (if advanced=false, with direct Clense method for killing spots)
osup   = o.MSuper(pel=2,sharp=2)
bv1    = osup.MAnalyse(isb=true, delta=1,blksize=8,overlap=4,search=4)
fv1    = osup.MAnalyse(isb=false,delta=1,blksize=8,overlap=4,search=4)
bc1    = o.MCompensate(osup,bv1)
fc1    = o.MCompensate(osup,fv1)

Interleave(fc1,o,bc1)

advanced ? RemoveDirtMod(limit,anim,repmode) : Clense()

SelectEvery(3,1)

comp ? StackHorizontal(o,last) : last
}

# From function RemoveDirt, original adaptation thanks to johnmeyer
Function RemoveDirtMod(clip input, int "limit", bool "anim", int "repmode")
{
 d  = anim ? 1 : 3
 dm = anim ? 1 : 2
 pt = anim ? 4 : 6
 ct = anim ? 6 : 8
 clensed = input.Clense()
 alt = input.RemoveGrain(dm)
 restore = (repmode==2) ? TemporalRepair(clensed, input, mode=4) : Repair(clensed, input, mode=16)
 return RestoreMotionBlocks(clensed,restore,alternative=alt,neighbour=input,pthreshold=pt,cthreshold=ct, gmthreshold=40,
 \ dist=d,dmode=dm,debug=false,noise=limit,noisy=12)
}
__________________
By law and justice!

GMJCZP's Arsenal

Last edited by GMJCZP; 24th December 2021 at 13:18. Reason: Update to version 3.1 (added anim and repmode)
GMJCZP is offline   Reply With Quote
Old 26th July 2017, 08:49   #13  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Quote:
Originally Posted by GMJCZP View Post
I have made Didée's idea to remove spots
It seems to work well. Thanks a lot. Might I suggest a name change? When I'm looking to use a spot remover and I'm going down my list of functions. 'Primitive' just doesn't jump out as a spot remover. Since 'RemoveSpots' and 'RemoveDirt' are already taken, then how about 'SpotRemover'? Or maybe you can suggest a different but still relevant name? CrudBeGone. SpotEx. CleanUp. DirtClean. Your choice.

Yeah, I know. I can just change it myself. But it's your filter (and Didée's).

Last edited by manono; 26th July 2017 at 08:51.
manono is offline   Reply With Quote
Old 26th July 2017, 12:07   #14  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Just had something jump into my head, hows bout "SpotLess()" ?

EDIT: From my pop-up dictionary, "Completely neat and clean".
__________________
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; 26th July 2017 at 12:31.
StainlessS is offline   Reply With Quote
Old 26th July 2017, 13:20   #15  |  Link
GMJCZP
Registered User
 
GMJCZP's Avatar
 
Join Date: Apr 2010
Location: I have a statue in Hakodate, Japan
Posts: 744
Quote:
Originally Posted by manono View Post
It seems to work well. Thanks a lot. Might I suggest a name change? When I'm looking to use a spot remover and I'm going down my list of functions. 'Primitive' just doesn't jump out as a spot remover. Since 'RemoveSpots' and 'RemoveDirt' are already taken, then how about 'SpotRemover'? Or maybe you can suggest a different but still relevant name? CrudBeGone. SpotEx. CleanUp. DirtClean. Your choice.

Yeah, I know. I can just change it myself. But it's your filter (and Didée's).

manono, I named it because Didée used that expression and I wanted to respect it, in addition the "primitive" videos have these characteristics.

Let's do one thing, I'll modify the name for another one I had already thought of, but in the description I'll put some of this, lol.

PD: TinMan, I hope this function is always SpotLess ;-)
__________________
By law and justice!

GMJCZP's Arsenal

Last edited by GMJCZP; 26th July 2017 at 13:26.
GMJCZP is offline   Reply With Quote
Old 26th July 2017, 19:58   #16  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
SpotLess. Good one, StainlessS.
manono is offline   Reply With Quote
Old 26th July 2017, 20:44   #17  |  Link
Busty
Registered User
 
Join Date: Sep 2016
Posts: 9
wow, this seems to work really great.

Although, I notice that the result is somewhat softer than the input.

Can this script be tweaked to retain the original sharpness / detail?
Busty is offline   Reply With Quote
Old 26th July 2017, 21:55   #18  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,685
Given who suggested this name, perhaps it should be "SpotLessS"?
johnmeyer is offline   Reply With Quote
Old 27th July 2017, 02:51   #19  |  Link
GMJCZP
Registered User
 
GMJCZP's Avatar
 
Join Date: Apr 2010
Location: I have a statue in Hakodate, Japan
Posts: 744
Quote:
Originally Posted by johnmeyer View Post
Given who suggested this name, perhaps it should be "SpotLessS"?
Lol*1000.
__________________
By law and justice!

GMJCZP's Arsenal

Last edited by GMJCZP; 27th July 2017 at 12:29.
GMJCZP is offline   Reply With Quote
Old 2nd August 2017, 05:21   #20  |  Link
GMJCZP
Registered User
 
GMJCZP's Avatar
 
Join Date: Apr 2010
Location: I have a statue in Hakodate, Japan
Posts: 744
Now to the function KillerSpots I have added a "advanced" mode, which produces better performance (at least I noticed in a test video) and also makes the function more configurable when defining a "limit" parameter, which by the way Is totally equivalent to the parameter present in the RemoveDirtMC function developed by johnmeyer.
__________________
By law and justice!

GMJCZP's Arsenal
GMJCZP 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 07:18.


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