Log in

View Full Version : Extract vertical scratches from silent films


anton_foy
27th November 2023, 16:25
So I have been using Spotless followed by makediff before and after it. Works good most of the time to extract the dust and sporadic scratches yet some frames needs to be removed as the filtering sometimes catches movement in the scene etc.

The next step I was hoping to extract vertical (almost static) scratches but it seems harder than I thought.
DestripeV is the only script that has been working somewhat to recognize the vert-scratches but alot of other things are detected and makes for unusable result.

My idea is that somehow make a detection and isolation of the vertical "anomalies" in the image that are scratches.

I have tried to isolate the scratches by masking with ex_edge("kroon") and inverted overlayed motion masks but to no avail.

May need another approach, ideas?

johnmeyer
27th November 2023, 17:14
Have a look at the discussion about ProPainter in this recent thread:

Big green line removal with overlay mask possible? (https://forum.doom9.org/showthread.php?t=184550)

Go to post #16.

Until seeing that thread, I would have told you that scratch removal was impossible without a lot of manual intervention because scratches persist from one frame to the next, so you can't use the trick of looking at something which doesn't exist in either the previous or next frame and then removing that (this is how dust removal algorithms work).

Selur
27th November 2023, 17:43
I would additionally recommend trying DeScratch.
(First DeScratch, afterwards SpotLess or similar was often a good approach.)

johnmeyer
27th November 2023, 20:49
By all means try Descratch. It is very easy to set up and use. However, I've never had it do anything very useful, so don't get your hopes up too high.

anton_foy
28th November 2023, 08:15
Thanks everyone, I did not yet try ProPainter but Descratch I have tried and have tweaked and adjusted the params but it seems to miss the scratches mostly and instead identifies other objects as such. Gotta be more careful which scenes I pick to do this on.

kedautinh12
28th November 2023, 12:06
Can you share your sample?

anton_foy
28th November 2023, 12:38
Can you share your sample?

Yes of course thanks! I will this evening. :)

johnmeyer
28th November 2023, 16:59
The big problem with Descratch is that (I think) it is basically a static inpainter, like a delogo filter. However, scratches wander slightly from frame to frame and therefore are not static enough for the painting to work consistently.

anton_foy
28th November 2023, 20:39
ReCan you share your sample?

it is 5gb :scared:
Problem is that I have to do selectevery(3, 1, 4).selectodd()
Otherwise I get duplicate frames.

link to youtube video: https://www.youtube.com/watch?v=LVV7UutK0Xk

My script so far:
converttoyv12()
Crop(482, 0, -480, 0)
u=last
cd=convertToYv12()
pr=cd.ex_median("IQMV",Y=3,UV=1)
pre=pr.ex_sbr(3,uv=1)

/*
mo=mmask2()
es=ex_edge("kroon").overlay(mode="darken",mo.invert().mt_expand())
ds=es.descratch(mindif = 12, asym = 6, maxgap = 3, maxwidth = 7).DeStripeV(3,1,255,uv=1).overlay(mode="darken",mo.invert().mt_expand())
mt_makediff(es,ds)
*/

SpotLess(RadT=3, pel=1, tm=false, blksz=8, chroma=false, thsad=520, dc=pre) #bb0.7
mt_makediff(last, u).invert()

#trim(7020, 7127)
selectevery(3, 1, 4).selectodd()
#trim(9827, 9912)
#trim(3183, 3491)
#trim(23399, 23446)
#trim(24414, 24586)++trim(24658, 24681)++trim(25222, 25327)
trim(36373, 36637)

last.awarpsharp2(depth=26).NNEDI3CL(1, dh=true, dw=true).SinPowResizeMT(2878,2160)

prefetch(16)

function MMask2(clip C)
{
## requires MVTools2
C ## Last==C
super = MSuper
fvec = MAnalyse(super, isb=false)
MMask(super, fvec, ml=100, gamma=0.5,
\ kind=0, Ysc=0, thSCD1=400, thSCD2=130)
Grayscale
Crop(0, 2, C.Width, C.Height, true)
return Last.Levels(0, 1, 128, 0, 255, coring=false)
}


Edit: I realize now that the descratch part is totally wrong. I forget that I experimented late at night and overwrote the previous script. Sorry