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 26th April 2025, 23:48   #1  |  Link
VideoMilk78
Registered User
 
VideoMilk78's Avatar
 
Join Date: Oct 2024
Location: Nebula 71 Star
Posts: 51
Better Dirt Removal Method..?

I've recently received scans to some martial arts films. Most dirt removal methods e.g. spotless, removedirtmc, and remove spots all remove limbs and what not... I've looked into delta restore but it's just not suitable for my needs, the closest I've gotten is Despot with the adjustable max spot size but the actual cleaning part of despot isn't great. I have already figured out a motion compensation algorithm but am not versed in Avisynth enough to tackle actual dirt removal. These are my requirements:

1. A dirt removal method that has the ability to specify minimum and maximum horizontal and vertical spot size
2. Is able to fill in colored scratches with minimum splotches
3. Has minimum effect on the grain although if this is a tradeoff I can deal with it

Thanks in advance
VideoMilk78 is offline   Reply With Quote
Old 27th April 2025, 10:02   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,164
Posted elsewhere [for Descratch]:
Quote:
Originally Posted by StainlessS View Post
DeScratch is a Spatial only filter to remove eg scratches on film.
To be of much use it would need be used before any temporal processing that would migrate the scratches to other frames,
making the problem more difficult to correct. As such, I would say that it would need to be applied before anything
else in your current script.
I have had limited success with Descratch, but very light settings can help, it also has a nasty habit of removing vertical edges that
should be there, eg telegraph poles sometimes disappear.


Posted elsewhere [for Despot]:

Quote:
Code:
blur (from 0 to 4, default 1)
Value (length) of local spatial blur near borders of deleted spots

tsmooth (from 0 to 127, default 0)
Control temporal smoothing in static areas (except spots and motion).
Set approximate threshold of pixel luma variance in 3 frames,
The more variance exceed this threshold, the less temporal smoothing.
0 - no temporal smoothing.
Blur, I think only affects a little area around a removed spot, should not really be a problem.

Suggest never use tsmooth (ever), but especially if doing mulitple passes of despot with different parameters.

EDIT: Using tsmooth will migrate non-removed spots into adjacent frames making them un-removable
in future despot passes.


tsmooth is frame global except where spots removed, without tsmooth, only alters frame where spots are fixed.
So, if doing multiple Despots at differing spot sizes, always use tsmooth=0, except maybe on last Despot instance, and/or no additional temporal processing later.

Some despot stuff from long ago:- https://forum.doom9.org/showthread.p...58#post1444658 # oops fixed link

Some Descratch stuff from long ago:- https://forum.doom9.org/showthread.p...42#post1688042
__________________
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; 27th April 2025 at 10:21.
StainlessS is offline   Reply With Quote
Old 27th April 2025, 22:55   #3  |  Link
VideoMilk78
Registered User
 
VideoMilk78's Avatar
 
Join Date: Oct 2024
Location: Nebula 71 Star
Posts: 51
Thanks for the recommendation, another question I have is whether or not Despot can utilize more than F,O,B? Can I use more vectors? Up to 5 would be ideal...


Docs state this
Quote:
bool mc = false
Uses a 3-fold interleaved stream to allow motion-compensated analysis. Only the second frame every three frames is processed and returned. The input stream should be in the form: Interleave (forward, original, backward), where forward and backward are the frames N-1 and N+1 reconstructed with motion compensation. See the MVTools2 plug-in for more information.
VideoMilk78 is offline   Reply With Quote
Old 28th April 2025, 08:52   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,164
Quote:
Can I use more vectors? Up to 5 would be ideal...
The mc arg was added after my last serious use of DeSpot [linked post was 2010, mc arg added 2013].
Dont think so, sorry.
There is no example use of mc arg in docs, but there is example usage of motion compensated despot in despot docs
:- http://avisynth.nl/index.php/DeSpot
Code:
# Example script with external mask from MVTools2 (you may tune optional MAnalyse parameters): 
AviSource("Blah.avi")
i = last
prefilt = i.DeGrainMedian() # prefiltered for better motion analysis

# analyse and compensate motion forward and backward (to current frame)
ml = 100     # mask scale
thscd1 = 400 # scene change

super=i.MSuper() # super clip
superprefilt = prefilt.MSuper() # super filtered clip

vf = superprefilt.MAnalyse(isb=false) # forward vectors 
cf = i.MFlow(super, vf, thscd1 = thscd1) # previous compensated forward
sadf = i.MMask(vf, ml=ml,kind=1,gamma=1, thscd1 = thscd1) # forward SAD mask
msadf = sadf.MT_Binarize(20, upper=true) # binary inverted forward SAD mask

vb = superprefilt.MAnalyse(isb=true)  # backward vectors 
cb = i.MFlow(super, vb, thscd1 = thscd1) # next compensated backward 
sadb = i.MMask(vb, ml=ml, gamma=1, kind=1, thscd1 = thscd1) # backward SAD mask
msadb = sadb.MT_Binarize(20, upper=true) # binary inverted backward SAD mask

msad = MT_Logic(msadf,msadb,"or") # combined inverted SAD mask
msad = msad.MT_Expand() # expanded inverted SAD mask
msadi = Interleave(msad, msad, msad) # interleaved 3-frame inverted SAD mask
# This mask is high (255) where at least one motion estimation is good, 
# so these areas will be protected

Interleave(cf,i,cb) # interleave forward compensated, source, and backward compensated

DeSpot(p1=30,p2=12,pwidth=800,pheight=600,mthres=20,merode=33,\
   sign=0,show=0,seg=0,color=true,motpn=true, extmask=msadi)

SelectEvery(3,1) # get filtered source
which looks not too dissimilar to DeNoiseNEW() in 2010 linked thread.

If you do (desperately) want to try 2 forward / 2 backward vectors, then you would need achieve that yourself, and avoid the mc arg thingy,
and pluck out the middle frame of every 5 on completion.

Perhaps someone else knows how best to add the additional vectors into the mix. [I just dont feel up to it ]

EDIT: Actually, I dont think that you can use 2 fwd, 2 bkwd, I dont think it makes sense, the despot thingy works by
compare with adjacent frames, not by adjacent AND adjacent +/- 1 frames, so it dont make sense, (at least to me).
EDIT: Sounds to me like the mc arg just does the equivalent of the SelectEvery(3,1) above in CODE block in BLUE.
__________________
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; 28th April 2025 at 09:17.
StainlessS is offline   Reply With Quote
Old 28th April 2025, 23:39   #5  |  Link
VideoMilk78
Registered User
 
VideoMilk78's Avatar
 
Join Date: Oct 2024
Location: Nebula 71 Star
Posts: 51
Does removedirt (restore motion blocks) only have access to first and last or is it static? If this is the case then if it can work with more than backw/forw then shouldn't despot with mc=false work the same? If not knowing your skill would it not be pretty easy to modify it to do so?
VideoMilk78 is offline   Reply With Quote
Old 29th April 2025, 11:52   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,164
Sorry, no can do, perhaps others with more experience of "removedirt (restore motion blocks)" and such can help,
I dont spend that much time with Avisynth or D9 nowadays.
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 29th April 2025, 18:45   #7  |  Link
VideoMilk78
Registered User
 
VideoMilk78's Avatar
 
Join Date: Oct 2024
Location: Nebula 71 Star
Posts: 51
Alright, no worries. I ended up figuring out a good solution for the actual cleaning However another problem has come up and that is the fact that Despot doesn't support HDR
VideoMilk78 is offline   Reply With Quote
Old 10th May 2025, 17:27   #8  |  Link
Busty
Registered User
 
Join Date: Sep 2016
Posts: 18
@ VideoMilk78:

would you mind sharing your "good solution"? I'd like to try that on some VHS captures with errors a bit similar to scratches.
Busty is offline   Reply With Quote
Old Yesterday, 17:15   #9  |  Link
VideoMilk78
Registered User
 
VideoMilk78's Avatar
 
Join Date: Oct 2024
Location: Nebula 71 Star
Posts: 51
It will not work on VHS material
VideoMilk78 is offline   Reply With Quote
Old Yesterday, 17:18   #10  |  Link
VideoMilk78
Registered User
 
VideoMilk78's Avatar
 
Join Date: Oct 2024
Location: Nebula 71 Star
Posts: 51
Here are some results on film
left=original
middle=cleaned
right=difference



VideoMilk78 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 15:30.


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