Log in

View Full Version : Remove vertical line


Bluedraft
26th July 2025, 02:30
Hello,

Is there any way to remove vertical lines like this
https://i.ibb.co/hRCqsSzC/frame.png (https://ibb.co/hRCqsSzC)

That line is across a short scene of 4sec in the source, here is the sample
https://short-link.me/18TDF

I tried descratch and spotless but without much luck

johnmeyer
26th July 2025, 02:45
The scratch seems to be very stable. You therefore might be able to get good results using Delogo. Years ago I produced a video showing how you could remove a sensor spot, but the same technique will work for the scratch. Here is the link:

Tutorial on Delogo Filter for Virtualdub (https://youtu.be/Z12TutFSg8c?si=rNZJQbZue6SCc1r5)

Bluedraft
26th July 2025, 02:55
Interesting, I'll give it a try, thanks John!

Selur
26th July 2025, 07:31
Using Vapoursynth:
clip = core.descratch.DeScratch(clip=clip,mindif=3,mindifuv=5,modeu=3,modev=3,maxwidth=5,maxlen=800)
seems to work fine. (should work with Avisynth too)
https://i.ibb.co/Nngzh3Dg/grafik.png (https://ibb.co/0Vp3NX4p)
But some inpainting or delogo will work fine also.

Cu Selur

Bluedraft
26th July 2025, 19:12
Thanks for your help Selur, It actually works well on the image, but in the video sample it leaves some traces of the line, as the dirt is not static. Anyway, I'll keep trying Descratch a little longer to see what happens.

StainlessS
26th July 2025, 23:11
Selur,
Your processed image looks quite a bit lighter (to my lousy eyes) than the original. (yellowish background),
is there some additional processing (blurring or other), other than descratch-ing via your VS script ?
EDIT: I assume that same process was used to create both original and output images.

Anyway, maybe below comes in handy to affect only scratch area.
Avisynth Descratch Improvement :- https://forum.doom9.org/showthread.php?t=185917

[click little blue arrow after 1st line "StainlessS" below (for script post)]
You're lucky, I only usually visit once per day for a few minutes.

How bout this, I integrated the AreaOp thingy. (totally untested).

/*
DescratchArea():- https://forum.doom9.org/showthread.php?p=2010311#post2010311
as for Descratch but area processed X,Y,W,H, specified as for crop(x,y,w,h), Original Descratch args Left and Right NOT USED.
Supported color formats: YV12, YV16, YV24, as for Descratch.
Coords MUST be crop compatible with colorspace eg all mod 2 for YV12, else error.
x,y,w,h, coords of inner area as per crop(x,y,w,h), w and h can be <= 0 where width or height relative.

Prototype (with defaults):
DescratchArea (clip, int "x"=0, int "y"=0, int "w"=0, int "h"=0,
\ int "mindif"=5, int "asym"=10, int "maxgap"=3, int "maxwidth"=3, int "minlen"=100, int "maxlen"=4096, float "maxangle"=5,
\ int "blurlen"=15, int "keep"=100, int "border"=2, int "modeY"=1, int "modeU"=0, int "modeV"=0, int "mindifUV"=0, bool "mark"=false, int "minwidth"=1)

Default x=0, y=0, w=0, h=0, is full frame. To skip eg 16 pixels from right use w=-16.

With exception of x,y,w,h, MOST other args are just passed on and defaulted within Descratch(),
Left and Right are passed to Descratch as 0, ie we are selecting area ourselves. # Actually now not passed, defaulted in Descratch.

*/

Function DescratchArea(clip c , int "x, int "y", int "w", int "h",
\ int "mindif", int "asym", int "maxgap", int "maxwidth",
\ int "minlen", int "maxlen", int "maxangle", int "blurlen", int "keep", int "border", int "modeY", int "modeU", int "modeV",
\ int "mindifUV", bool "mark", int "minwidth" )
{
x = default(x, 0) # We set defaults for our new args,
y = default(y, 0) # others args just passed on and defaulted within Descratch().
w = default(w, 0)
h = default(h, 0)

# Make w and h -ve or 0, ie width or height relative.
w = (w <= 0) ? w : (x + w) - c.Width()
h = (h <= 0) ? h : (y + h) - c.Height()

Area=c.crop(x,y,w,h) # Inner Area

# Borders, Full width top and bottom, short height left and right
Above = (y>0) ? c.crop(0,0,c.width(),y) : NOP
Below = (h<0) ? c.crop(0,c.Height()+h,c.width(),0) : NOP
Left = (x>0) ? c.crop(0,y,x,h) : NOP
Right = (w<0) ? c.crop(c.Width+w,y,0,h) : NOP

Area.Descratch(
\ mindif=mindif,asym=asym,maxgap=maxgap,maxwidth=maxwidth,minlen=minlen,maxlen=maxlen,maxangle=maxangle,
\ blurlen=blurlen, keep=keep, border=border, modeY=modeY, modeU=modeU, modeV=modeV, mindifUV=mindifUV,mark=mark,minwidth=minwidth,
\ ) # BUG REMOVED "left=0, right=0", let them default inside Descratch.


IsClip(Left) ? StackHorizontal(Left, Last) : NOP
IsClip(Right) ? StackHorizontal(Last, Right) : NOP
IsClip(Above) ? StackVertical(Above, Last) : NOP
IsClip(Below) ? StackVertical(Last, Below) : NOP
Return Last
}


EDIT: Descratch on Wiki:- http://avisynth.nl/index.php/DeScratch
Note, you had default maxlen=100, should have been maxlen=2048 [EDIT: Oops, 4096] as on wiki.

EDIT:

When args not supplied by caller, then is UnDefined on entry to the function, you can pass an Undefined arg to eg DeScratch where it will do the
equivalent to arg = Default(arg, Some_Default_Value)


EDIT: OOps, below in blue was period '.' not comma ','.

Area.Descratch(
\ mindif=mindif,asym=asym,maxgap=maxgap,maxwidth=maxwidth,minlen=minlen,maxlen=maxlen,maxangle=maxangle,
\ blurlen=blurlen, keep=keep, border=border, modeY=modeY, modeU=modeU, modeV=modeV, mindifUV=mindifUV,mark=mark,minwidth=minwidth,
\ left=0, right=0)


EDIT: If "right=0" in call to DeScratch causes problem, then change to 2048 [EDIT: Oops, 4096] as in below from Wiki.

or remove ", right=0" altogether and let Descratch default it, YES, thats probably the best solution.
I'll change in code above.
EDIT: REMOVED the lot, ie "left=0, right=0", both defaulted inside Descratch.

EDIT: You would of course need a little extra area around the scratch, to enable Descratch() to work properly.

Selur
27th July 2025, 04:48
@Stainless: might be caused by modeu or spotless which I also had active, but I didn't actively/intentionally mess with the colors. (I mainly thought that DeScratch should work and messed with its settings.)
DeScratch with the defaults with mindif=1,maxwidth=5 should be enough.
https://i.ibb.co/5X0NFNwc/grafik.png (https://ibb.co/4wq6d63N)

VideoMilk78
4th August 2025, 03:59
I gave up on descratch ages ago, at this point someone needs to make a new algorithm and new plugin

johnmeyer
4th August 2025, 17:29
Scratches on movie film are very difficult to remove because they don't move much and they persists for many frames, sometimes for a minute or more. As a result, when doing a film transfer, most professional transfer operations use a "wet gate" transfer where the film is first coated with a thick liquid which fills the scratches and optically solves the problem.

Scratches can still be removed, if that wet gate process is not done, or if the "scratch" is some sort of artifact baked into a video, but like many things done with professional film restoration, software scratch removal requires a lot of operator intervention.

While software keeps getting smarter, I am not aware of any low-cost software tool that can successfully remove scratches, although the method I recommended above will work if the scratch doesn't move.

StainlessS
4th August 2025, 22:23
And it is very unlikely to ever be a 'one-size-fits-all', have to manually set ranges/positions etc for each scratch.
Just wait till the day you have to fix 2000 single frame edits in a single clip.
(well in my case was 'want to' rather than 'have to', not sure if I will ever want-to again)
And with scratches, have to restrict area so as not to destroy telegraph poles and lamp posts, or tree trunks.

johnmeyer
4th August 2025, 23:37
And it is very unlikely to ever be a 'one-size-fits-all', have to manually set ranges/positions etc for each scratch.
Just wait till the day you have to fix 2000 single frame edits in a single clip.
(well in my case was 'want to' rather than 'have to', not sure if I will ever want-to again)
And with scratches, have to restrict area so as not to destroy telegraph poles and lamp posts, or tree trunks.Yes. This is exactly why commercial movie film restoration employs dozens of technicians because they often have to manually identify individual defects.

Emulgator
5th August 2025, 12:27
Besides all the valuable explanations of my colleagues I would like to mention InpaintDeLogo as a possible way to consider.
Not that I have tried it on that source, but maybe I should, time permitting...

coolgit
23rd August 2025, 10:02
I had this problem years ago when i started editing. At the end, since the line are static, I used photoshop. Worked very well.