Log in

View Full Version : Removing thin vertical lines from Video


S_Prince
26th July 2014, 15:47
Hello all,

I was watching a Hindi movie named 'Kabzaa',it is from my DVD collection and authored by Music India. It was a real pain while watching because the colors were too dull. So I had decided to encode it with my choice of colors and remove noises. While checking the source I found that it contains vertical thin lines all over it. Tried some ways to remove them but nothing helped.

i am providing my used script along with a screenshot of a frame and an uncompress sample for better verification


QTGMC(preset="medium")
srestore(frate=25)

crop(14, 2, -16, -2)
LanczosResize(632,472) # Lanczos (Sharp)
MCTemporalDenoise(settings="low")
HDRAGC(max_sat=1.3, avg_lum=500, coef_gain= 0.5, min_gain=1.0, max_gain=4.3,shift_u=-15)


Screenshot :

http://i.imgur.com/j9yTH49.png

Uncompress SAMPLE(Video only.No audio):
https://www.sendspace.com/file/xcz3do

Any help will be appreciated

Thanks,

StainlessS
26th July 2014, 16:03
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.

S_Prince
26th July 2014, 16:20
Using Descratch in default mode did not helped. So can you give some parameters for this source?

I only used :Descratch()

Thanks for your reply. :)

johnmeyer
26th July 2014, 16:44
Your problem looks like film scratches. If this is indeed a film source, then you need to check whether it must first be IVTC'd. Descratch will not work on a film source (24 fps) that has been telecined up to 30 fps (actual speed 29.97 fps).

The RemoveDirt plugin can sometimes remove certain scratches. There is a motion compensated version of that called RemoveDirtMC.

S_Prince
26th July 2014, 16:54
Your problem looks like film scratches. If this is indeed a film source, then you need to check whether it must first be IVTC'd. Descratch will not work on a film source (24 fps) that has been telecined up to 30 fps (actual speed 29.97 fps).

The RemoveDirt plugin can sometimes remove certain scratches. There is a motion compensated version of that called RemoveDirtMC.
It looked like a PAL To NTSC conversion to me. So I tried to bob it and then restore back 25fps with srestore. I shall try RemoveDirtMC and will post the result here soon. Thanks for replying. :)

S_Prince
26th July 2014, 17:17
I have just used RemoveDirtMC. But it did nothing :(

Any more suggestions?

StainlessS
26th July 2014, 18:14
I've downloaded a little of your source, was taking too long so I stopped at 27secs of source.
You must establish if it needs IVTC first.
There is no magic script that will remove all scratches all of the time and leave telegraph poles etc intact.
Last time I used Descratch (a couple of years ago), I ended up spending about 2 weeks doing only that.
You can target for eg only thin lines, or thick lines, or black line or white lines, and do the whole thing in multiple passes.
You can however target both black and white at same time, multipass will though be more specificly targetted,
When I had the misfortune to have to use descratch, I also used ClipClop() (or RemapFramesSimple does same sort of thing I believe)
to only use on specific frames. On the same clip I had to use descratch, I also had to use DeSpot, another pain, ended up after
spending lots of time despotting/descratching hand editing 2500+ frames where hand edit means some kind of single frame correction,
which may have been only to undo results of a bad descratch/despot.
Anyway, script here is maybe a start from what I remember about the plugin, be prepared to spend a lot of time to do it right.

Global GMINDIF = 2 # YOUR default setting, def 5, 2 = quite aggessive, detects faint scratches
Global GKEEP = 100 # ditto, def 100. # Less than 100 lose more of scratch but perhaps more of image too
Global GMAXANGLE = 0 # ditto, def 5


Function ThinBlack(clip Last,int "mindif",int "Keep",int "MaxAngle") {
mindif=Default(mindif,GMINDIF)
keep=Default(keep,GKEEP)
MaxAngle=Default(MaxAngle,GMaxAngle)
DeScratch(maxwidth=1, modeY=1,mindif=mindif,maxgap=3, minlen=50, maxlen=1000, maxangle=MaxAngle, blurlen=15, keep=keep)
}

Function ThickBlack(clip Last,int "mindif",int "Keep",int "MaxAngle") {
mindif=Default(mindif,GMINDIF)
keep=Default(keep,GKEEP)
MaxAngle=Default(MaxAngle,GMaxAngle)
DeScratch(maxwidth=3, modeY=1,mindif=mindif,maxgap=3, minlen=50, maxlen=1000, maxangle=MaxAngle, blurlen=15, keep=keep)
}

Function ThinWhite(clip Last,int "mindif",int "Keep",int "MaxAngle") {
mindif=Default(mindif,GMINDIF)
keep=Default(keep,GKEEP)
MaxAngle=Default(MaxAngle,GMaxAngle)
DeScratch(maxwidth=1, modeY=2,mindif=mindif,maxgap=3, minlen=50, maxlen=1000, maxangle=MaxAngle, blurlen=15, keep=keep)
}

Function ThickWhite(clip Last,int "mindif",int "Keep",int "MaxAngle") {
mindif=Default(mindif,GMINDIF)
keep=Default(keep,GKEEP)
MaxAngle=Default(MaxAngle,GMaxAngle)
DeScratch(maxwidth=3, modeY=2,mindif=mindif,maxgap=3, minlen=50, maxlen=1000, maxangle=MaxAngle, blurlen=15, keep=keep)
}

Function ThinBoth(clip Last,int "mindif",int "Keep",int "MaxAngle") {
mindif=Default(mindif,GMINDIF)
keep=Default(keep,GKEEP)
MaxAngle=Default(MaxAngle,GMaxAngle)
DeScratch(maxwidth=1, modeY=3,mindif=mindif,maxgap=3, minlen=50, maxlen=1000, maxangle=MaxAngle, blurlen=15, keep=keep)
}

Function ThickBoth(clip Last,int "mindif",int "Keep",int "MaxAngle") {
mindif=Default(mindif,GMINDIF)
keep=Default(keep,GKEEP)
MaxAngle=Default(MaxAngle,GMaxAngle)
DeScratch(maxwidth=3, modeY=3,mindif=mindif,maxgap=3, minlen=50, maxlen=1000, maxangle=MaxAngle, blurlen=15, keep=keep)
}

# Return Clip Difference of input clips (amp==true = Amplified, show==true = show background)
Function ClipDelta(clip clip1,clip clip2,bool "amp",bool "show") {
amp=Default(amp,false)
show=Default(show,false)
c2=clip1.levels(128-32,1.0,128+32,128-32,128+32).greyscale()
c1=clip1.subtract(clip2)
c1=(amp)?c1.levels(127,1.0,129,0,255):c1
return (show)?c1.Merge(c2):c1
}

Avisource("U.avi").ConvertToYV12()
ORG=Last
Assumetff

Thickboth(mindif=2,keep=100,maxangle=0)

AMP=True
SHOW=True

D=ClipDelta(Last,ORG,amp=AMP,show=SHOW)

TOP=StackHorizontal(ORG,Last)
BOT=StackHorizontal(D,D)
StackVertical(TOP,BOT)

EDIT: Added arg to funcs and used global defaults

A good idea to step through whole video frame by frame to see if you lost any telegraph poles, and recover the frame if so (clipclop).

Above script, I've only changed two args, 1st two in script functions, MaxWidth and ModeY.
Given script is reasonably aggressive, perhaps enough for you if you dont want to spend weeks on it.
Maxangle of 0, will only descratch perfectly vertical scratches, if you want to descratch those that are not perfectly
vertical then set to eg 5 but may cause damage, be prepared to recover bad frames.

EDIT: All I could tell from what I downloaded was that it is TFF, hard to tell anything else from a clip where only the lips move.
TIP, best samples to provide are those with continuous movement, about 30 secs is usually enough.

EDIT: ClipClop allows you to replace original clip with one of up to 255 clips (eg descratched with different settings, or to eg recover a single frame from the original clip after descratching a range, RemapFramesSimple only copes with 1 alternative clip [I believe, I never have call to use it]).)

S_Prince
26th July 2014, 18:21
Thanks for the new & hopeful solution. I shall take a look at it shortly and let you know about the output.

Thanks, :)

EDIT:

I have just tried your given method and it gave me excellent result.The lines are looking very thin now and they are hardly visible. Thanks a lot for your help!

Screen of same frame provided in the OP using the modified script :

http://i.imgur.com/UMqK7YV.png

I had provided the sample to show where the lines are mostly visible. So my bad. Shall try to provide a sample with movement later on..

Thanks,