Log in

View Full Version : DeScratch plugin for film line scratch removing


Fizick
31st December 2003, 02:15
I develop DeScratch filter for restoration of my old 8 mm films, may be it will be useful to somebody else.

http://bag.hotmail.ru

morsa
31st December 2003, 05:41
Fizick please pay a look to restoreinpaint source code.
It will let you remove bigger scratchs and pops with excellent quality.
http:\\restoreinpaint.sourceforge.net

It uses digital inpainting techniques to restore lost portions of images with great and amazing results.
You can get big support from its developer.
I hope, in some near future it could be used to remove hardcoded subtitles, not only for ripped DVD, but for old films where some portions of it has been recovered from positive copies with subtitles.

Fizick
31st December 2003, 19:08
Morsa, you may do it yourself.
Try.

morsa
31st December 2003, 20:28
Sorry, but I can't.I don't know how to code anything.
I wasn't asking you to do something for me, just giving you this info in case you find it useful or anybody else find it useful.
I thought you were interested in improving the filter.

Fizick
1st January 2004, 00:29
1. You can to learn programming.
Standard C is quite simple.
I see your similar posts during about year.
I am not a real programmer too (only FORTRAN long ago).
But if I really needed something, and it is absent, I try do it myself.

Sorry for mentor notes.

2. Thanks for info and links.
I saw it month ago (seemed from you).
But that methods probably is not appropriate to video.

3. My filter works for my video quite well.

4. With what video did you try my filter?
And with what parameters settings?
Can you show one frame from with your scratches.

Yuri
3rd January 2004, 02:35
Fizick, the filter is great but it also falsely triggers not noise - like snowflakes in cartoon material. Is there a way out of fine-tuning the filter?
Thank you, compatriot:)

Fizick
7th January 2004, 19:25
Try to increase minlen parameter.
May your present one frame with snow?

Yuri
8th January 2004, 00:26
Certainly, two 2-frame sequences are here:
http://sch-yuri.narod.ru/DVD/images/snowflake-fur-fizick-1.jpg
http://sch-yuri.narod.ru/DVD/images/snowflake-fur-fizick-2.jpg
http://sch-yuri.narod.ru/DVD/images/snowflake-fur-fizick-3.jpg
http://sch-yuri.narod.ru/DVD/images/snowflake-fur-fizick-4.jpg
My best regards

Fizick
8th January 2004, 20:51
Very nice snow. (From what film is it?)
But my main question:
Where are the scratches in these frames?

Yuri
9th January 2004, 04:13
It's a Russian animated cartoon "Tigryenok na podsolnukhye" (A Tiger Cub on a Sunflower). Dearest Fizick, any scratches are not here the problem but the white snowfalkes themselves, because they are triggered as spots or blobs, which is the sad portion of the story!

Fizick
9th January 2004, 18:37
Dear Yuri!
The more I read your posts, the more I think, that you talk about my DeSpot filter (former CTMEDIAN), but not about DeSratch filter!
If so, please answer in another thread (an with with more detailed description of your problem):
http://forum.doom9.org/showthread.php?s=&threadid=59388

Yuri
12th January 2004, 00:33
That could be very true! Because I tried one of the two filters of yours but I don't remember which one. Anyway, I'll try the both and post the results.
My warmest regards
yuri

Fizick
14th July 2004, 19:22
New optimized version of DeScratch is released.
Version 0.3, July 14, 2004 - ported to native Avisynth plugin,
Speed increased due to fast blurring by Avisynth resizing functions.
(From 2 to 15 fps !)
http://bag.hotmail.ru/descratch/descratch.dhtml

Recently we can see a great guide to analog capture at doom9.
But one part of this guide is not very great ;)
It has name "Removal of clicks and scratches"
http://www.doom9.org/capture/descratch.html
Ivo try use DeSpot for VHS horizontal line-drops removing.
I think, that DeScratch is more appropriate tool for descratch :)
(however is not ideal - current version process only luma plane).
Of course, you must rotate clip for processing with Descratch (and do not forget rotate it in reverse direction after cleaning :D ).

Example (VHS source from Ivo)
http://bag.hotmail.ru/descratch/linedrop.jpg


loadplugin("descratch.dll")
Avisource("drop-outs_.avi")
converttoYV12()
crop(0,0,-0,288) # select top part of frame to save screen space
input=last
assumetff()
separatefields() # for analog interlaced source
turnleft()
descratch(mindif=4,maxgap=20,minlen=300,blurlen=50,keep=100,border=0,maxangle=0)
turnright()
weave() # restore fields
# Compare source frame and frame after scratch removing
StackVertical(input,last)

toysoldier
15th July 2004, 07:40
Fizick comrade:

I dream to write myself filter,
but there very little guide in this site.
Can you give me some guide
how to make avisynth or virtualdub's filter with vc++?
Maybe you can introduce your great filters writing procedureH

Thanks a lot!

Wilbert
15th July 2004, 09:25
For AviSynth:

http://www.avisynth.org/FilterSDK -> SimpleSample

For VirtualDub, trevlac made a nice intro page. But, I don't have the link here.

toysoldier
15th July 2004, 12:12
@Wilbert:
thank you for your quickly answer.

trevlac has gave me a helpness,his guide in this site:
http://trevlac.us/vdubGuide/Overview.htm

this is neuron2 gave me some guide :

http://neuron2.net/ipw-web/bulletin/bb/viewtopic.php?t=453

thanks these warmheart people : trevac,neuron2,wilbert...

Fizick
17th July 2004, 20:09
Toysoldier,
look to Simplesample source! Avisynth plugins is simpler than V.Dub.

To all.
Version 0.4, released July 17, 2004
Added chroma processing: modeY, modeU, modeV parameters,
introduced in version 0.4 after Ivo's request (old versions can process luma only).

Fizick
2nd August 2004, 22:33
Version 0.5, July 31, 2004
fixed read-write pointer bug,
add "mindifUV" parameter for separate control of chroma U,V planes cleaning,
some code reorganization,
documentation corrected.


I4004 make update of article about VHS drop-outs removing with Descratch.
http://neuron2.net/ipw-web/bulletin/bb/viewtopic.php?t=524

EddieTH
3rd August 2004, 17:04
I found this thread while I was looking for filters for my Star Trek DVDs, which have a lot of scratches, especially on the previews, which don't seem to have been cleaned up at all before encoding. Using DeScratch I was able to make small (but noticeable) improvements in the episodes and major improvements to the previews. Great filter!

killer_jaime11
19th February 2005, 07:03
Hi people
I have scratches in my video in the form of lines of different colours or distorted. I'm trying Fizick's DeScratch and I've looked for information on Fizick's web and tried the following configuration, it's the same as said on the web but I added asym=1 since the filter marked thicker lines that what I expected.
However, I'm still worried about the quantity of "noise" marked by the filter since I don't see any horizontal lines where nearly all marks are present...
Sincerely, I don't know where to start tweaking the parameters since I've read them all but have no idea. As a start I would like the filter not to detect as many horizontal scratches as it does now...
What values should I change??? Here I leave you a copy of my script

AviSource("C:\Ripeos\Cruz y raya\capture00.avi")
Trim(0,38467) ++ Trim(47733,66002)

#Fizick's DeSpot
loadplugin("C:\Archivos de programa\AviSynth 2.5\plugins\descratch.dll")
ConvertToYV12(interlaced=true)
crop(0,0,-0,288) # select top part of frame to save screen space
input=last
assumetff()

separatefields() # for analog interlaced source
turnleft()
descratch(asym=1,mindif=4,maxgap=20,minlen=300,blurlen=50,keep=100,border=0,maxangle=0.0, mark=true, modeU=1, modeV=1)
turnright()
weave() # restore fields
# Compare source frame and frame after scratch removing
StackVertical(input,last)

And here an image with an example of what I mean by the filter marking too much:
http://gipa20.webcindario.com/1intento.bmp

Fizick
19th February 2005, 23:50
Dear killer, :)

1. All scratches marked by Descratch on your example are weak scratches, which will NOT be cleaned.

2. Only strong (with dif > mindif) and long (length > minlen) scratch will be cleaned by Descratch.
It would be marked by deep black.

3. IMHO, I do not see any line on you example for Descratch.
Try DeGrainMedian instead.
or some other filter (fft3d ?).

killer_jaime11
20th February 2005, 20:59
Hi Fizick
Thanks for answering that quickly, I've been trying to tune your filter starting off with the parameters on your page but I don't get the right settings, I've tried increasing mindif and minlen to get less detection, also I turned on the modeU and modeV and put mindifUV=0 so it gets mindif. But the problem is that the scratches that I want to be removed don't get removed, scratches like this:

http://gipa20.webcindario.com/intento22.bmp

This is the only kind of scratch I need to remove from my clip. What settings do you suggest me to use Fizick?? Also I'm getting detected other parts of the clip which aren't scratches. The Avisynth code used is:

#Fizick's DeSpot
loadplugin("C:\Archivos de programa\AviSynth 2.5\plugins\descratch.dll")
ConvertToYV12(interlaced=true)
crop(0,0,-0,288) # select top part of frame to save screen space
input=last
assumetff()

separatefields() # for analog interlaced source
turnleft()
descratch(mindif=4,maxgap=20,minlen=110,blurlen=50,keep=100,border=0,maxangle=0.0,modeU=1,modeV=1,mindifUV=0, mark=false)
turnright()
weave() # restore fields
# Compare source frame and frame after scratch removing
StackVertical(input,last)

Also, I've noticed a strange image, see what I've got:

http://gipa20.webcindario.com/intento21.bmp

No idea why the face of the man is distorted, I thought it could be because of the detection marking but it's turned off.
Thanks in advance

Fizick
13th March 2005, 11:26
One user (UFFE) sent to me this e-mail.
Some video sources like Laserdiscs sometime have spots and scratchs that are almost the same size all the time, but if you try to remove them with despot or descratch you often get many false corrections. I would like to know if it is possible to add these functions:
A "maxlen" parameter for descratch to determin the maximum length of a scratch, this could be very usefull if you only want to remove scratches that are almost the same length.
"minpwidth" and "minpheight" parameters for despot to determin the minimum size of a spot, this could be very usefull if you only want to remove spots that are almost the same size.

So, now I release Descratch Version 0.8, March 13, 2005 - added maxlen parameter

grannyGeek
14th September 2006, 07:11
Souce clip has many vertical scratches & lines, looks a lot like the screenshot in DeScratch guide.
I tried the small sample script in the guide,

AviSource("whatever.avi")
LoadPlugin("descratch.dll")
ConvertToYV12()
DeScratch(lumadif=2)



Using in VirtualDubMpeg2, and it won't load, gives error message
"DeScratch does not have named argument "lumadif"


Which current parameter replaced lumadif ?
Or is that an obsolete setting now?

what would be the simplest script for DeScratch?

Thanks for any help.

Fizick
15th September 2006, 04:39
mindif
I fixed the doc (and released the source code)

grannyGeek
15th September 2006, 06:36
Thank you sir!
appreciate your filters more than I can say
I'm still bragging about my good results with DeSpot
:)

marknyc5
24th August 2011, 03:54
I've created an avs file, but see no effect at all. I've been trying different scripts and here is the latest. This is for a black and white film with black vertical scratches. What am I doing wrong in the script?

Thanks for any help!

Mark

DirectShowSource("lemonade.avi")
LoadPlugin("descratch.dll")
ConvertToYV12()
DeScratch(mindif=5)
DeScratch(maxgap=55)
DeScratch(keep=0)
DeScratch(mark=true)

Emulgator
24th August 2011, 09:29
You will not want to call Descratch 4 times in row with only one parameter.
I guess you will want to call Descratch only once with your 4 parameters separated by commas.

The Descratch.html gives examples. Like

DeScratch(mindif=4, maxgap=20, minlen=300, blurlen=50, keep=100, border=0, maxangle=0)

Besides there are many occasions where Descratch will find nothing. The scratch width is still limited to 1 pixels or 3 pixels.

Bernardd
31st May 2016, 13:52
Hello Fizick,

Thanks you for the last release of Descratch. The strach corrections are now very good, it is difficult with a picture tool like Gimp to get faster and better correction.
The new args left and right are genius. With them, it is more easy to find a common tune of values for long frames serial.

I believe it would be more perfect, if the no process area would be between rigth and left, when arg left is superior than arg right.

Thanks

Transatlantic
11th July 2017, 18:05
I have been using Descratch for some time on Super 8 mm and 8 mm restoration projects.

I was quite pleased, although there were cases where it was inapplicable, especially if the scene contained a number of vertical objects, such as a fence or vertical posts.

I had noticed that vertical scratches very often appear in the same area of the image. In my case on the right hand side of the image. This is probably due to mechanical friction in movie projectors.
It is only recently that I realized that Descratch was updated to version 1.1 to include “right” and “left” parameters (amongst other improvements).

This is just what I dreamed of! I can now apply more aggressive parameters to the scratched area without risking false detections in other areas.

This is a vast improvement. And setting the right parameters is much easier, because you can concentrate on the area containing scratches, and disregard the area that does not contain scratches…

Other improvements are also welcome, such as more “maxwidth” values… and “more smooth scratch borders removing”.

:thanks: Thank you very much for this excellent updated version! :thanks:

:confused: By the way, there is one parameter that is still some sort of mystery to me: that is “asym”. I have not been able to make out what it actually does and how to tweak it. Maybe it is difficult to explain in words, but easy with a picture… Can anyone explain, or show this on a picture? :confused:

Patrick

from Brittany, France

kedautinh12
29th November 2023, 12:59
Latest ver Adds YV16 and YV24 support.
https://github.com/vapoursynth/descratch/releases

tormento
29th November 2023, 17:17
Latest ver Adds YV16 and YV24 support.

Dues it work for AVS+ too?

ChaosKing
29th November 2023, 17:39
"Note that in VapurSynth all arguments are fully lowercased. Also comes with Avisynth support."

kedautinh12
30th November 2023, 00:52
Note: "A combined VapourSynth+Avisynth verion of the the DeScratch filter written by Fizick"