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 24th August 2020, 16:26   #1  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,132
SpotLess v1.06 - 08 Jan 2021

Script filter to remove spots and noise using mvTools2 and Medianblur2.
Copes with spots on multiple consecutive frames, setting RadT accordingly.
Mvtools2/MedianBlur2 by Pinterf, so AVS+ colorspace and x64 compatible.
Based on an idea by Didée.
Originally posted here:- https://forum.doom9.org/showthread.p...83#post1921583

Code:
/*
    SpotLess v1.06. temporal spot/noise remover, by StainlessS @ Doom9.   https://forum.doom9.org/showthread.php?t=181777
    Original idea from Didée post :-                                      https://forum.doom9.org/showthread.php?p=1402690#post1402690
    Req:- Pinterf MvTools2(), Pinterf Medianblur2() with MedianBlurTemporal rather than the MedianBlurT() from Didée post.
          With appropriate plugins, will be AVS+ colorspace and x64 compatible.
          Fine using Avs+ Prefetch() so long as current Pinterf plugins, and Frame Accurate source. RequestLinear() following the source filter might suffice as frame accurate source filter.

    NOT FOR cartoon/anime, live video only, sorry.

    v1.01, Remove RadT Max check. Add MSuper(hpad=16,vpad=16). Add BlkSz arg.
    v1.02, Add some stuff.
    v1.03, Frame size auto config of args removed (found instances where caused problems). Added Glob and bBlur args.
    v1.04, Script breaking changes, I guess is more flexible if can also set ThSAD, inserted ThSAD 3rd arg. RadT now default 1, was 2, dont over denoise unless requested.
    v1.05, Additional checks on args.
    v1.06, Glob Default true, Almost always better.

    SpotLess(clip c,int "RadT"=1,int "ThSAD"=10000,int "ThSAD2"=ThSAD,int "pel"=2,bool "chroma"=true, int "BlkSz"=8,Int "Olap"=BlkSz/2,
            \ bool "tm"=true,Bool "glob"=True,Float "bBlur"=0.0)

    RadT, 1 or more, Default 1. Removes Spots on up to RadT [Temporal Radius] consecutive frames.
        RadT > 2 will usually be overkill. Setting too high could possibly result in blurring.
        Each pixel in result frame is median pixel value of (2*RadT+1) motion compensated frames (including source, ie current_frame-RadT to current_frame+RadT).

    ThSAD, Default 10000=NEARLY OFF(ie ignore hardly any bad blocks), 0 < ThSAD < 16320(8*8*255). 8x8 block SAD threshold at radius 1 (ie at current_frame +- 1) [SAD, Sum of Absolute (pixelwise) Differences].
        ThSAD and ThSAD2 suggested absolute minimum of maybe about 400.
        ThSAD and ThSAD2 thresholds are based on 8 bit 8x8 block, irrespective of colorspace depth or BlkSz, max=8x8x255=16320, use same thresholds where High Bit Depth.
        In mvTools MCompensate(), when creating a compensated block the SAD between compensated block and the same original block in current_frame, the 8 bit SAD is measured and if
        greater than SAD threshold then that block is ignored and uses original block from current frame instead. [The compensated block is judged too different, so ignored & original block used instead
        in the result MCompensated frame].
        Where eg ThSAD=64, AVERAGE absolute single pixel difference threshold would be 64/(8*8)=1, so AVERAGE absolute pixel difference greater than 1 would ignore that mcompensated block and use the
        block from current frame in the resulting mcompensated frame instead. This example allows for all pixels in a 8x8 block to be different by 1, or a single pixel in 8x8 block to be different by 64,
        or some other mixture.
          A problem with above is, if a low ThSAD and current_frame block is mostly noise, so compensated blocks could be judged bad because they are too different to the bad noisey block, and the result
        block may/will be just as bad as the noisy source block. A possible solution to this problem is to have a higher SAD threshold and/or have a bigger BlkSize so that the number of bad source pixels
        after converting/scaling to as if an 8x8 block, will contain fewer bad noise pixels. So, SpotLess BlkSz arg would ideally maybe 4 or more times the area of the largest spots that you have, and a SAD
        threshold big enough so as to not ignore the block [ wild guess minimum SAD threshold for big spot sizes of (8x8x255)/4 = 4080 ].
        Where a complete source frame is bad, then maybe should have very high (eg 10000) SAD threshold, and BlkSz may not really matter too much.
          It is not the end of the world if some of the compensated blocks are ignored and swapped for the original current_frame block. Nor is it the end of the world if
        no blocks were ignored because of high SAD threshold. The final result pixel is median pixel value of (2*RadT+1) motion compensated blocks, so allowing for some mistakes by choosing the
        middle pixel value.
        I've just tested real bad double frame, full frame luma and chroma corruption, with below line:
            SpotLess(RadT=5,ThSAD=1000000,ThSAD2=1000000,pel=2,chroma=false,BlkSz=8,Olap=4,tm=false,glob=false,bBlur=0.0)
        And although both SAD thresholds of 1 million, are totally impossible and so no blocks could possibly be ignored and yet we still got pretty good results, all frames were fixed
        as we still had the temporal median filter to fall back on and pick the middle pixel value.

        From mvtools2 docs:
          ThSAD is SAD threshold for safe (dummy) compensation.
              If block SAD is above the thSAD, the block is bad, and we use source block instead of the compensated block. Default is 10000 (practically disabled).

    ThSAD2, Default ThSAD, 0 < ThSAD2 < 16320(8*8*255), Lower removes fewer spots, but less chance of blurring.
        ThSAD2 sets the SAD [Sum of Absolute Differences] threshold for most distant frame from current_frame at distance RadT, with those frames that are distances in-between 1 and RadT
        acquiring a SAD threshold linearly interpolated between the two.
        From mvtools2 docs:
          ThSAD2:
              Defines the SAD soft threshold for the furthest frames at current_frame +- RadT.
              The actual SAD threshold for each reference frame is a smooth interpolation between the original thSAD (close to the current frame)
              and thSAD2. Setting thSAD2 lower than thSAD allows large temporal radii and good compensation for low SAD blocks while reducing the global error and the
              risk of bluring when the result of MCompensate is passed to a temporal denoising filter.
        EDIT: Although I have said that SAD threshold being too high could result in blurred frames, that is really taken from above "risk of bluring" line from mvtools docs,
        however, that warning says "temporal denoising filter", which might suggest pixel averaging, whereas we are using pixel median. I'm not sure that blurring would be the result
        of having too high a SAD threshold.

    Pel,     Default 2. 1, 2, or 4. Maybe set 1 for HD+. (1=precision to pixel, 2=half pixel, 4=quarter pixel)

    Chroma,  Default True. MAnalyse chroma arg. If true, use chroma in block matching when creating vectors. Maybe use False if source B&W or color noise.

    BlkSz,   Default 8. MAnalyse BlkSize. Bigger blksz quicker and perhaps better for HD clips. [Info: current Pinterf MvTools allows for BlkSize=12, and overlap=6]

    OLap,    Default half BlkSz, Block overlap.

    Tm,      TrueMotion Default True. Some folk swear truemotion=false is better.

    Glob,    Default True (True v1.06, was same as Tm, true almost always better), Allow set MAnalyse(global) independently of TrueMotion.
             From MvTools2 docs for MAnalyse,
               global
                 Estimate global motion (at every level) and use it as an additional predictor.
                 Only pan shift is estimated (no zoom and rotation).
                 Use false to disable, use true to enable.

    bBlur,   Default 0.0 [OFF]. If used, Suggest about 0.6, where MAnalyse create vectors is performed on denoised (blurred) super clip.
*/

Function SpotLess(clip c,int "RadT",int "ThSAD",int "ThSAD2",int "pel",bool "chroma", int "BlkSz",Int "Olap",bool "tm",Bool "glob",Float "bBlur") {
    myName = "SpotLess: "
    RadT     = Default(RadT,1)        # Temporal radius. (MCompensate arg)
    ThSAD    = Default(ThSAD,10000)   # SAD threshold at radius 1 (Default Nearly OFF).
    ThSAD2   = Default(ThSAD2,ThSAD)  # SAD threshold at radius RadT.
    Pel      = Default(pel,2)         # Default 2. 1, 2, or 4. Maybe set 1 for HD+. (1=precision to pixel, 2=precision to half pixel, 4=quarter pixel)
    Chroma   = Default(chroma,True)   # MAnalyse chroma arg. If set to true, use chroma in block matching.
    BlkSz    = Default(BlkSz,8)       # Default 8. MAnalyse BlkSize. Bigger blksz quicker and perhaps  better, esp for HD clips. Maybe also better where BIG noise.
    OLap     = Default(OLap, BlkSz/2) # Default half of BlkSz.
    Tm       = Default(tm,True)       # TrueMotion, Some folk swear MAnalyse(truemotion=false) is better.
    Glob     = Default(glob,True)     # Default True, Allow set MAnalyse(global) independently of TrueMotion.
    Bblur    = Default(bblur,0.0)     # Default OFF
    Assert(1 <= RadT,myName + " 1 <= RadT")
    Assert(0.0 <= bblur <= 1.58, myName + "0.0 <= bblur <= 1.58")
    Assert(pel==1 || pel==2 || pel==4, myName + "pel==1 || pel==2 || pel==4")
    pad      = max(BlkSz,8)
    sup      = (bBlur<=0.0  ? c   : c.blur(bblur)).MSuper(hpad=pad,vpad=pad,pel=pel,sharp=2)
    sup_rend = (bBlur<=0.0) ? sup : c.MSuper(hpad=pad,vpad=pad,pel=pel,sharp=2,levels=1) # Only 1 Level required where not MAnalyse-ing.
    MultiVec = sup.MAnalyse(multi=true, delta=RadT,blksize=BlkSz,overlap=OLap,chroma=Chroma,truemotion=Tm,global=Glob)
    c.MCompensate(sup_rend, MultiVec, tr=RadT, thSad=ThSAD, thSad2=ThSAD2)
    MedianBlurTemporal(radiusY=0,radiusU=0,radiusV=0,temporalradius=RadT)  # Temporal median blur only [not spatial]
    SelectEvery(RadT*2+1,RadT)                                             # Return middle frame
}
Hacked this for a clip with spots on double frames, did not know if would be much better, but as it turns out is fandabbydozy.

Chosen function name would seem to be a very good choice, not perfect, but very nearly is.

Adjective: spotless
1) Completely neat and clean

Quote:
Originally Posted by ChaosKing View Post
You should also try spotless as a prefilter in smdegrain. Worked very good for me with almost zero artifacts left from spotless.
Quote:
Originally Posted by real.finder View Post
yes, it's do better job than any methods ...
Quote:
Originally Posted by Boulder View Post
This is a wonderful tool. As it happens, I've been cleaning a VHS cap and the silly video has quite a lot of spots and scratches in every other field. SpotLess cleans them up nicely and also takes care of most of the chroma noise too.. I haven't checked things with longer samples but looks good anyway.
__________________
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; 8th January 2021 at 18:35. Reason: Update
StainlessS is offline   Reply With Quote
Old 25th August 2020, 16:15   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,132
Quote:
Originally Posted by StainlessS View Post
Perhaps someone would like to test SpotLess() on 'old cartoon' which is subject of this thread.
I dont usually touch cartoon/anime at all, and even less 'old cartoon'.
I not sure that Mvtools copes well with cartoon at all.
Quote:
Originally Posted by lansing View Post
It doesn't work on anime, it wiped out all moving objects in motion scenes.
So not much good for cartoon/anime, sorry.
__________________
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 26th August 2020, 13:15   #3  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,132
If you've got a clip with a big dollop of black crap (spot) at frame edge which is not removed by SpotLess, may possibly
be removed by eg AddBorders(32,32,32,32,$808080) prior to SpotLess and Crop(32,32,-32,-32) afterwards.
I had one of 4 frame duration which was successfully removed with RadT=6, [maybe I should up RadT max to 8 or 10 or something, for one-offs].
Will likely not work if 1st or last spot near scene change.

EDIT: My spot would seem to be a film burn hole [dont know what they are called].
EDIT: MSuper( ..., hpad=32,vpad=32) [ EDIT: inside of Spotless] dont do it, gotta Addborders pad with grey or white to get rid of black spot).
EDIT: Weird, was working fine, now only removes 2 of the 4 spots, ???
EDIT: I may have modified prior color correction since the time it removed all 4 spots, still only removing 2 spots.

[EDIT: Frame Top Right Hand corner] Source spot, burn in near vacinity of other dark object

Spotless fixed

Next frame, Not Fixed (well modified a bit but) is too close now to dark object

The color correction that I changed somehow previously allowed fix, but not now, forgot what prev color correction was.
__________________
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; 26th August 2020 at 16:15.
StainlessS is offline   Reply With Quote
Old 26th August 2020, 14:53   #4  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Hollola, Finland
Posts: 5,061
Quote:
Originally Posted by StainlessS View Post
EDIT: My spot would seem to be a film burn hole [dont know what they are called]
I think that's called "a cigarette burn" I wouldn't be surprised if they actually were those back in the day.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 26th August 2020, 15:01   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,132
Change from
Code:
 
MultiVec = sup.MAnalyse(multi=true, delta=RadT,blksize=8,overlap=4,search=4)
To
Code:
MultiVec = sup.MAnalyse(multi=true, delta=RadT,blksize=32,overlap=16,search=4)
Allows detect and removal of above posted spot, I'll make Blocksize selectable.
Spot from above bottom image Now gone [as is the last of the 4 spots also removed, so all 4 spots now gone].


EDIT
Cigarette burn, well I thought could happen when reel stopped spinning and projector lamp still hot.
__________________
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; 26th August 2020 at 15:14.
StainlessS is offline   Reply With Quote
Old 26th August 2020, 15:51   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,132
1st post updated script.
Code:
    v1.01, Remove RadT Max check. Add MSuper(hpad=16,vpad=16). Add BlkSz arg.
EDIT:
Adding hpad, vpad greater than 8, assists when changing framerate, avoids oscillating effects at frame edge sometimes, will not do any harm to also have it here.
__________________
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; 26th August 2020 at 15:54.
StainlessS is offline   Reply With Quote
Old 26th August 2020, 15:59   #7  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Hollola, Finland
Posts: 5,061
Quote:
Originally Posted by StainlessS View Post
EDIT
Cigarette burn, well I thought could happen when reel stopped spinning and projector lamp still hot.
My thought was more nostalgic, like people cutting the film while smoking heavily and dropping ashes and sparks all over the place
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 26th August 2020, 16:08   #8  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,132
Yeh, you're problably correct in my particular spot instance, think projector lamp burns were not always totally symmetrical.

Nostalgia, its not what it used to be. [stolen from some D9 guys sig].

Maybe I should set hpad/vpad to same as BlkSz, when above 8.

Also, ClipClop, [or ReplaceFramesSimple] could be used to apply special instance SpotLess args to awkward ranges where spots resist fixing.
__________________
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; 26th August 2020 at 17:08.
StainlessS is offline   Reply With Quote
Old 26th August 2020, 16:43   #9  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,132
Clipclop script
Code:
AviSource(".\Play_1.avi")
O=Last
SpotLess()  # Apply Spotless(Radt=2,Blksz=8) to entire clip

FIX1=O.AddBorders(32,32,32,32,$808080).Spotless(RadT=4,BlkSz=32).Crop(32,32,-32,-32) # Special clip index 1
FIX2=O.AddBorders(32,32,32,32,$808080).Spotless(RadT=5,BlkSz=32).Crop(32,32,-32,-32) # Special clip index 2

SCMD= """
    1 28251,28254   # Replace fix range 28251,28254 using FIX1 [clip index 1]
    2 30001,30005   # Replace fix range 30001,30005 using FIX2 [clip index 2]

"""

ClipClop(Last,FIX1,FIX2,scmd=SCMD)  # also has file commands. Max 255 replacement clips [unlimited replacment ranges]
StackHorizontal(O,Last)
ClipClop:- https://forum.doom9.org/showthread.p...light=Clipclop

EDIT: Its like magic Now to go back and try fix non removed large frame edge spot that I did yesterday.

Or mod

Code:
AviSource(".\Play_1.avi")
O=Last
SpotLess(2)  # Apply Spotless(Radt=2,Blksz=8) to entire clip

FIX1=O.EdgeKludge(4) # Special clip index 1
FIX2=O.EdgeKludge(5) # Special clip index 2

SCMD= """
    1 28251,28254   # Replace fix range 28251,28254 using FIX1 [clip index 1]
    2 30001,30005   # Replace fix range 30001,30005 using FIX2 [clip index 2]

"""

ClipClop(Last,FIX1,FIX2,scmd=SCMD)  # also has file commands   # BUGFIX, ClipClop(Last ... NOT ... ClipClop(O
StackHorizontal(O,Last)

Return Last

Function EdgeKludge(clip c,Int RadT,Int "BlkSz", Int "Border") {
    BlkSz=Default(BlkSz,32)
    Border=Default(Border,32)
    Return c.AddBorders(Border,Border,Border,Border,$808080).Spotless(RadT=RadT,BlkSz=BlkSz).Crop(Border,Border,-Border,-Border)
}
__________________
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; 26th August 2020 at 23:23.
StainlessS is offline   Reply With Quote
Old 26th August 2020, 19:24   #10  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Metropolitan City of Milan, Italy
Posts: 1,414
Quote:
Originally Posted by Boulder View Post
I think that's called "a cigarette burn" I wouldn't be surprised if they actually were those back in the day.
Is it?
I don't know whether we're talking about the same thing and I might be wrong but to me it looks like a cue mark, which was used to let the projectionist know that the reel was close to the end or that it reached a certain length. Even though those things were used way before I was even born, I actually found 'em in some of the very old contents I'm Remastering and in the recording-sheet they were saying like "Cue Mark at " and so on
FranceBB is offline   Reply With Quote
Old 26th August 2020, 19:26   #11  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Hollola, Finland
Posts: 5,061
Quote:
Originally Posted by FranceBB View Post
Is it?
I don't know whether we're talking about the same thing and I might be wrong but to me it looks like a cue mark, which was used to let the projectionist know that the reel was close to the end or that it reached a certain length. Even though those things were used way before I was even born, I actually found 'em in some of the very old contents I'm Remastering and in the recording-sheet they were saying like "Cue Mark at " and so on
You could well be right, especially if you've run into those like that
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 26th August 2020, 19:55   #12  |  Link
Frank62
Registered User
 
Join Date: Mar 2017
Location: Germany
Posts: 138
Quote:
Originally Posted by FranceBB View Post
I actually found 'em in some of the very old contents
I find these every week in for-me-not-so-old-content. Round or sometimes square. If the content is worth it, we fix it by hand, but this way looks quite elegant. Will give it a try. Thanks @StainlessS again!
Frank62 is offline   Reply With Quote
Old 26th August 2020, 20:22   #13  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,132
There were so many fag burns, all in same-ish position, and all 4 frames duration, so FBB probably correct.
The 4 frame replacements in the script are nearly all, 'fag burns'.


The 'border color' prob, imported a few pixels of the gray addborders into where the burn was, probably due to burn surround color being mid green (close to mid grey),
so I changed the kludge fliter to use YUV PC Levels white, and that fixed the grey imports.
One of the spots fixes caused a little bit of blurring on fast moving obect, but way better than the burn, so left it [maybe could do special fix to apply just to spot 1/4 of frame,
or through mask, but probably gonna leave it, so hard to notice.
At one point, had mid frame bad full frame width vhs breakup, maybe 30 or 40 pixels tall, and also full frame desaturation, kludge fixed both perfectly, hehe.

Script used
Code:
AviSource(".\Play_1.avi")
O=Last
SpotLess(2)  # Apply Spotless(Radt=2,Blksz=8) to entire clip

FIX1 = O.EdgeKludge(1)
FIX2 = O.EdgeKludge(2)
FIX3 = O.EdgeKludge(3)
FIX4 = O.EdgeKludge(4)
FIX5 = O.EdgeKludge(5)
FIX6 = O.EdgeKludge(6)
FIX7 = O.EdgeKludge(7)
FIX8 = O.EdgeKludge(8)
FIX9 = O.EdgeKludge(9)

SCMD= """
3 1756,-3    # ripple  [-3 means 3 frames, instead of start,end frames]
4 28251,-4   #
1 28352      # single frame
4 28426,-4
4 51911,-4
4 78032,-4
4 78208,-4
4 105201,-4    # attn, change to border color = YUV PC levels white
4 105377,-4
7 122341,-7
4 127242,-4    # attn, desat
4 127418,-4
8 130004,-8    # film stratch
4 133844,-4
"""

ClipClop(Last,FIX1,FIX2,FIX3,FIX4,FIX5,FIX6,FIX7,FIX8,FIX9,scmd=SCMD)  # also has file commands : BUGFIX: NOT ClipClop(O, but ClipClop(Last,
StackHorizontal(O,Last)

Return Last

Function EdgeKludge(clip c,Int RadT,Int "BlkSz", Int "Border",int "ColYUV") {
    BlkSz=Default(BlkSz,32)
    Border=Default(Border,32)
    ColYUV=Default(ColYUV,$FF8080)  # YUV PC RANGE WHITE

    Return c.AddBorders(Border,Border,Border,Border,Color_yuv=ColYUV).Spotless(RadT=RadT,BlkSz=BlkSz).Crop(Border,Border,-Border,-Border)
}
EDIT: Not sure, but I think the original SpotLess(RadT=2) also fixed a single full frame dropout, I did not notice it in the fixed version.

Didee really should have pushed his idea more, this thing is bloody marvelous.
EDIT: GMJCZP did KillerSpots() function, but only single frame fixes.

EDIT: Above I used EdgeKludge() funcs, even for non edge problems, just saved time not doing separate functions.

EDIT: BUGFIX in above script, did not matter to me as I had already called Spotless(2) creating the input AVI
__________________
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; 3rd November 2020 at 16:05.
StainlessS is offline   Reply With Quote
Old 8th September 2020, 21:40   #14  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,132
SpotLess Update v1.02. See 1st post.
Code:
   SpotLess v1.02. temporal spot/noise remover, by StainlessS @ Doom9. https://forum.doom9.org/showthread.php?t=181777
    Original idea from Didée post :-                                    https://forum.doom9.org/showthread.php?p=1402690#post1402690
    Req:- Pinterf MvTools2, Pinterf Medianblur2() with MedianBlurTemporal rather than the MedianBlurT() from Didée post.
          With appropriate plugins, will be AVS+ colorspace and x64 compatible.

    NOT FOR cartoon/anime, live video only, sorry.
    v1.01, Remove RadT Max check. Add MSuper(hpad=16,vpad=16). Add BlkSz arg.
    v1.02, Add some stuff.

    RadT, 1 or more, Default 2. Removes Spots on up to RadT consecutive frames.
        RadT > 2 will usually be overkill. Setting too high could possibly result in blurring [no problems encountered so far at RadT=6].
    ThSAD2, 400 <= ThSAD2 <= 10000, Default 10000=NEARLY OFF. Lower removes fewer spots, but less chance of blurring.
        Reduce if produces blurred frames, absolute minimum of maybe about 400, probably pretty good as is.
        Lower reduces effect of bad non matching blocks, reduced more so on blocks from more distant radii frames.
        ThSAD for frame @ distance 1 defaults to 10,000 [and we let it default], ThSAD2 sets the SAD [Sum of Absolute Differences] threshold
        for most distant frame at distance RadT, with those frames that are distances in-between being given a SAD threshold linearly spread between the two.
        Wild guess that maybe about 10000 at RadT=1, and 5000 (10000/2) where RadT=6, might be a good compromise if concerned about blurring.
        Suggested, based on wild guesses above :) [if you experience blurred results, otherwise leave as is]
          Where below RadT is 6, and ThSAD2=5000, then blocks @ frames current_frame +- 6 gets weighted SAD threshold value of 5000 (same as ThSAD2),
          @ current_frame +- 3, gets distance weighted SAD threshold value 8000, etc
            Radius  SAD threshold : Where RadT=1, SAD threshold=ThSAD2. Where RadT>1; SAD threshold=(RadT-Radius)*((10000-ThSAD2)/(RadT-1))+ThSAD2; (6-Radius)*((10000-5000)/(6-1))+5000.
            1          10000        10000, Almost switches OFF SAD thresholding at frame distance 1. [Ignores blocks of only really high SAD differences]
            2           9000
            3           8000        In between frames acquire SAD threshold value linearly between 10000 @ distance 1, and ThSAD2[here 5,000] at distance RadT[here 6].
            4           7000
            5           6000
            6           5000        Where RadT=6 and ThSAD2 = 5000, so frame @ distance 6 gets SAD threshold value of ThSAD2[5000]
          And to weight similar to above where eg RadT=3, set RadT=3, ThSAD2=8000 to set as above Radius=3,SAD threshold=8000. Radii 2 and 1 will acquire 9000 and 10000 resp.
        From mvtools2 docs:
          ThSAD is SAD threshold for safe (dummy) compensation.
              If block SAD is above the thSAD, the block is bad, and we use source block instead of the compensated block. Default is 10000 (practically disabled).
          ThSAD2:
              Defines the SAD soft threshold for the furthest frames.
              The actual SAD threshold for each reference frame is a smooth interpolation between the original thSAD (close to the current frame, EDIT: Default 10000)
              and thSAD2. Setting thSAD2 lower than thSAD allows large temporal radii and good compensation for low SAD blocks while reducing the global error and the
              risk of bluring when the result of MCompensate is passed to a temporal denoising filter.
        In SpotLess, we dont actually set mvtools ThSAD arg, only ThSAD2, ThSAD will default 10000, but where RadT=1 and you set ThSAD2 to eg 5000 it should (I hope)
        set soft SAD threshold at radii 1 to ThSAD2 [and override the ThSAD default 10000].
        If anybody can explain above any better, then please do. I hate doing docs and as you can see, I aint very good at it.
    Pel,     Default 2. 1, 2, or 4. Maybe set 1 for HD+. (1=precision to pixel, 2=precision to half pixel, 4=quarter pixel)
    Chroma,  Default True. MAnalyse chroma arg. If set to true. Use chroma in block matching.
    BlkSz,   Default c.width>960 ? 16 : 8. MAnalyse BlkSize. Bigger blksz quicker and perhaps better, esp for HD clips (Maybe on occasion 24 or 32).
    OLap,    Default half BlkSz, Block overlap.
    tm,      TrueMotion, False if BlkSz>8, else true. Some folk swear truemotion=false is better, NOTE MAnalyse Global will always be true.
EDIT: From MvTools2 docs for MAnalyse,
Quote:
global

Estimate global motion (at every level) and use it as an additional predictor.
Only pan shift is estimated (no zoom and rotation).
Use false to disable, use true to enable. Default is like truemotion.
We always set Global=true, even when Truemotion turned OFF.
__________________
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; 8th September 2020 at 21:51.
StainlessS is offline   Reply With Quote
Old 10th September 2020, 09:40   #15  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,132
SpotLess v1.03, update, see 1st post.

Code:
    SpotLess v1.03. temporal spot/noise remover, by StainlessS @ Doom9. https://forum.doom9.org/showthread.php?t=181777
    Original idea from Didée post :-                                    https://forum.doom9.org/showthread.php?p=1402690#post1402690
    Req:- Pinterf MvTools2, Pinterf Medianblur2() with MedianBlurTemporal rather than the MedianBlurT() from Didée post.
          With appropriate plugins, will be AVS+ colorspace and x64 compatible.

    NOT FOR cartoon/anime, live video only, sorry.
    v1.01, Remove RadT Max check. Add MSuper(hpad=16,vpad=16). Add BlkSz arg.
    v1.02, Add some stuff.
    v1.03, Frame size auto config of args removed (found instances where caused problems). Added Glob and bBlur args.

    SpotLess(clip c,int "RadT"=2,int "ThSAD2"=10000,int "pel"=2,bool "chroma"=true, int "BlkSz"=8,Int "Olap"=BlkSz/2,bool "tm"=true,Bool "glob"=Tm,Float "bBlur"=0.0)

    RadT, 1 or more, Default 2. Removes Spots on up to RadT consecutive frames.
        RadT > 2 will usually be overkill. Setting too high could possibly result in blurring [no problems encountered so far at RadT=6].
    ThSAD2, 400 <= ThSAD2 <= 10000, Default 10000=NEARLY OFF. Lower removes fewer spots, but less chance of blurring.
        Reduce if produces blurred frames, absolute minimum of maybe about 400, probably pretty good as is.
        Lower reduces effect of bad non matching blocks, reduced more so on blocks from more distant radii frames.
        ThSAD for frame @ distance 1 defaults to 10,000 [and we let it default], ThSAD2 sets the SAD [Sum of Absolute Differences] threshold
        for most distant frame at distance RadT, with those frames that are distances in-between being given a SAD threshold linearly spread between the two.
        Wild guess that maybe about 10000 at RadT=1, and 5000 (10000/2) where RadT=6, might be a good compromise if concerned about blurring.
        Suggested, based on wild guesses above :) [if you experience blurred results, otherwise leave as is]
          Where below RadT is 6, and ThSAD2=5000, then blocks @ frames current_frame +- 6 gets weighted SAD threshold value of 5000 (same as ThSAD2),
          @ current_frame +- 3, gets distance weighted SAD threshold value 8000, etc
            Radius  SAD threshold : Where RadT=1, SAD threshold=ThSAD2. Where RadT>1; SAD threshold=(RadT-Radius)*((10000-ThSAD2)/(RadT-1))+ThSAD2; (6-Radius)*((10000-5000)/(6-1))+5000.
            1          10000        10000, Almost switches OFF SAD thresholding at frame distance 1. [Ignores blocks of only really high SAD differences]
            2           9000
            3           8000        In between frames acquire SAD threshold value linearly between 10000 @ distance 1, and ThSAD2[here 5,000] at distance RadT[here 6].
            4           7000
            5           6000
            6           5000        Where RadT=6 and ThSAD2 = 5000, so frame @ distance 6 gets SAD threshold value of ThSAD2[5000]
          And to weight similar to above where eg RadT=3, set RadT=3, ThSAD2=8000 to set as above Radius=3,SAD threshold=8000. Radii 2 and 1 will acquire 9000 and 10000 resp.
        From mvtools2 docs:
          ThSAD is SAD threshold for safe (dummy) compensation.
              If block SAD is above the thSAD, the block is bad, and we use source block instead of the compensated block. Default is 10000 (practically disabled).
          ThSAD2:
              Defines the SAD soft threshold for the furthest frames.
              The actual SAD threshold for each reference frame is a smooth interpolation between the original thSAD (close to the current frame, EDIT: Default 10000)
              and thSAD2. Setting thSAD2 lower than thSAD allows large temporal radii and good compensation for low SAD blocks while reducing the global error and the
              risk of bluring when the result of MCompensate is passed to a temporal denoising filter.
        In SpotLess, we dont actually set mvtools ThSAD arg, only ThSAD2, ThSAD will default 10000, but where RadT=1 and you set ThSAD2 to eg 5000 it should (I hope)
        set soft SAD threshold at radii 1 to ThSAD2 [and override the ThSAD default 10000].
        If anybody can explain above any better, then please do. I hate doing docs and as you can see, I aint very good at it.
    Pel,     Default 2. 1, 2, or 4. Maybe set 1 for HD+. (1=precision to pixel, 2=precision to half pixel, 4=quarter pixel)
    Chroma,  Default True. MAnalyse chroma arg. If set to true. Use chroma in block matching.
    BlkSz,   Default 8. MAnalyse BlkSize. Bigger blksz quicker and perhaps better for HD clips.
    OLap,    Default half BlkSz, Block overlap.
    Tm,      TrueMotion Default True. Some folk swear truemotion=false is better.
    Glob,    Default Tm, Allow set MAnalyse(global) independently of TrueMotion.
             From MvTools2 docs for MAnalyse,
               global
                 Estimate global motion (at every level) and use it as an additional predictor.
                 Only pan shift is estimated (no zoom and rotation).
                 Use false to disable, use true to enable. Default is like truemotion.
    bBlur,   Default 0.0 [OFF]. If used, Suggest about 0.6, where MAnalyse create vectors performed on denoised (blurred) super clip.
Reverted some args, BlkSz=8, tm(truemotion)=true.
Found instances where fast-ish moving objects got swallowed up [a swift 'heil hitler' would do it], so reverted to safer defaults.
Added Glob, and 'bBlur args.

EDIT: From MvTools2 docs for MAnalyse,
Quote:
global

Estimate global motion (at every level) and use it as an additional predictor.
Only pan shift is estimated (no zoom and rotation).
Use false to disable, use true to enable. Default is like truemotion.
__________________
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; 13th September 2020 at 14:29.
StainlessS is offline   Reply With Quote
Old 10th September 2020, 10:14   #16  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,132
Here script that I've been using for SingleRate deinterlace of mixed Progressive / Interlaced PAL.
Removed from DBSC thread last post, as have changed it here.
I used SpotLess on pre-deinterlaced source, it seemed like a good idea at the time but causes fuzziness around eg eyes
and sort of prevents deinterlace where fuzzy.
So, moved SpotLess to after deinterlace, much better detail and acts as a sort of residual combing fixer.
I only use below for single rate deinterlacing [ie OUTPUT=0], the other modes being experimental.
Many oldish [80's] PAL TV sourced DVD's are mixes of interlaced and progressive, the one I've recently been 'doin' spotless for is interlaced video
color for indoor scenes, progressive for outdoor scenes, and progressive B&W for ancient footage.
Such PAL hybrid progressive/interlaced is quite often cursed with changing borders, I use this script prior to removing dynamically changing borders
with DBSC.

DGIndex template, DVD_PAL_Hybrid_DeintSingleRate.avs
Code:
### DGIndex Template, PAL_Hybrid_DeintSingleRate.avs
VideoFileName   ="__vid__"
AudioFileName   ="__aud__"
AudioDelay      =Value("__del__")

###############
# PAL Hybrid Interlaced/Progressive mix, output to singlerate or doublerate.
###############
MPEG2Source(VideoFileName)
AudioExt=RT_GetFileExtension(AudioFileName)

Audio=      (AudioExt==".ac3") ? NICAC3Source(AudioFileName,channels=2,DRC=0)
        \ : (AudioExt==".mpa"||AudioExt=="mp1"||AudioExt==".mp2"||AudioExt==".mp3") ? NicMPG123Source(AudioFileName,Normalize=False)
        \ : (AudioExt==".wav") ? RaWavSource(AudioFileName)
        \ : (AudioExt==".dts") ? NicDTSSource(AudioFileName)
        \ : 0

Assert(!isInt(Audio),"NO AUDIO")

(!isInt(Audio)) ? AudioDub(Audio).DelayAudio(AudioDelay).Trim(0,0) : NOP    # Trim, chop/add audio to length

(!isInt(Audio) && AudioRate() <> 44100) ? ResampleAudio(44100) : NOP
####### CONFIG ##########

AssumeTFF                                                        # Whatever (check) : Almost always TFF for PAL DVD. Default field order is BFF.

OUTPUT = 0      # 0=SingleRate 25FPS Progressive.    Progressive src frames as input, interlaced src frames are even frames from dbl rate deinterlacing.
                # 1=SingleRate 25FPS Hybrid.         Progressive src frames as input, interlaced src frames dbl rate deinterlaced, reinterlaced to 25FPS after processing.
                # 2=DblRate 50fps. Prog=ChangeFPS.   Progressive src frames doubled with ChangeFPS, interlaced src frames are dbl rate deinterlaced.
                # 3=DblRate 50fps. Prog=Interpolate. Progressive src frames double rate interpolated with JohnFPS [ie MvTools], interlaced src frames are dbl rate deinterlaced.

UNSPOT_P=True   # Use SplotLess() on Progressive parts to remove spots and noise.
UNSPOT_I=True   # Use SplotLess() on Interlaced parts to remove spots and noise.

RADT_P   = 2      # SpotLess temporal radius (spots on 2 consecutive frames)
ThSAD2_P = 5000  # Almost OFF.
BlkSz_P  = 8
Tm_P     = true
bBlur_P  = 0.6

FRAMES_P=1      # Progressive McDegrainSharp(frames=FRAMES_P), (0=Dont McDegrainSharp)
CSHARP_P=0.3

RADT_I   = 2     # SpotLess temporal radius (spots on 2 consecutive frames)
ThSAD2_I = 5000  # Almost OFF.
BlkSz_I  = 8
Tm_I     = true
bBlur_I  = 0.6

FRAMES_I=2      # Interlaced McDegrainSharp(frames=FRAMES_I), (Maybe double FRAMES_P for detail migration, although max possible for McDegrainSharp=3).  (0=Dont McDegrainSharp)
CSHARP_I=CSHARP_P

                # IsCombedTIVTC args, Defaults, 1st after comment hash.
CTHRESH = 8     # 10), Area combing threshold.
                # Valid settings are from -1 (every pixel will be detected as combed) to 255 (no pixel will be detected as combed).
                # This is basically a pixel difference value. A good range is between 8 to 12.
MI      = 80    # 80), Number of combed pixels inside any of the blocky by blockx size blocks on the frame for the frame to be detected as combed.
CHROMA  = True  # True), Whether or not chroma is considered in the combed frame decision. [We want chroma as interlaced parts in color]
BLOCKX  = 16    # 16), X-axis size of the window used during combed frame detection.
BLOCKY  = 16    # 16), Y-axis size of the window used during combed frame detection.
                # So in any single block, if 85[MI] out of 256[BLOCKX x BLOCKY] pixels pass CThresh as combed, then is Interlaced.
METRIC =  1     # 0) Detecto method: 0=Old, 1=New

                # Deinterlace mode
BOBMOD=1        # 0=BOB, 1=YadifMod2, 2=QTGMC : QTGMC here is way memory/CPU intensive, req x64. Suggest YadifMod2

BOB_FUNC_0 =    """Bob()"""                                                                                                    # Cheap & cheerful Doublerate simple Bob.
BOB_FUNC_1 =    """YadifMod2(Order=-1,Mode=1,edeint=NNedi3(Field=-2, nns=2))"""                                                # Doublerate Yadifmod2 filter.
                # # Field-2=double rate, internal parity value to start : Order-1=Internal Parity. Mode 1=double rate do spactial check (3=no spatial check).

BOB_FUNC_2 =    """QTGMC(Preset="fast",NoisePreset="Fast",SourceMatch=2,Lossless=2,EZKeepGrain=0.4,Sharpness=0.1, tr2=0)"""  # Doublerate QTGMC filter.

FUNC       =   Select(BOBMOD, BOB_FUNC_0, BOB_FUNC_1, BOB_FUNC_2)
FNAME      =   Select(BOBMOD,"BOB",      "YADIF",     "QTGMC")


PRE_FETCH=4    # 1 = No Prefetch, Else eg 4 = Prefetch(4) ie MT mode

###            # Display stuff
SUBS   = True  # Show where Deinterlaced/ReInterlaced
STACK  = True # Show Src and Result
TITLE  = False # Show Title Bar
TITNUM = True # Show Frame Number on Title Bar (Only if TITLE)
FINAL  = FALSE # True, switch off SUBS, STACK, and Title

##### End Config ##########

Src=Last

SUBS  = (!FINAL&&SUBS)
TITLE = (!FINAL&&TITLE)
STACK = (!FINAL&&STACK)


### IsCombedTIVTC with args, as a string eg "IsCombedTIVTC(cthresh=10,mi=85,chroma=true,blockx=16,blocky=16,metric=1)"
COMBDET = RT_String("IsCombedTIVTC(cthresh=%d,mi=%d,chroma=%s,blockx=%d,blocky=%d,metric=%d)",CTHRESH,MI,CHROMA,BLOCKX,BLOCKY,METRIC)
SUBTXT    = (OUTPUT==0) ? FNAME+"_DEINTERLACED-EVEN" : (OUTPUT==1) ? FNAME+"_RE-INTERLACED" : FNAME+"_DblRate-DEINTERLACED"

# Interlaced parts
# DeSpot, Deinterlace to doublerate, McDeGrainSharp to migrate detail between original fields[now frames].
Deint = Src.Eval(FUNC)  # Double Rate deinterlace
Deint = (OUTPUT==0)  ? Deint.SelectEven                                                  : Deint # If (OUTPUT==0) McDegrainSharp & SpotLess done after Deinterlace.SelectEven, Else after doublerate deinterlace.
Deint = (UNSPOT_I)   ? Deint.SpotLess(Radt=RADT_I,thsad2=ThSAD2_I,blksz=BLKSZ_I,tm=Tm_I,bBlur=bBlur_I) : Deint
Deint = (FRAMES_I>0) ? Deint.McDeGrainSharp(frames=FRAMES_I,csharp=CSHARP_I)             : Deint
Deint = (OUTPUT==1)  ? Deint.SeparateFields.SelectEvery(4,0,3).Weave                     : Deint # If singlerate Re-Interlacing
Deint = (SUBS)       ? Deint.Subtitle(SUBTXT,Align=5)                                    : Deint

# Progressive parts, Despot, Degrain sharp done still @ singlerate
Prog = Src
Prog = (UNSPOT_I)   ? Prog.SpotLess(Radt=RADT_P,thsad2=ThSAD2_P,blksz=BLKSZ_P,tm=Tm_P,bBlur=bBlur_P)  : Prog
Prog = (FRAMES_P>0) ? Prog.McDeGrainSharp(frames=FRAMES_P,csharp=CSHARP_P)              : Prog
Prog = (OUTPUT==2)  ? Prog.ChangeFPS(Src.FrameRateNumerator*2,Src.FrameRateDenominator) : (OUTPUT==3) ? Prog.JohnFPS() : Prog # Progressive to O/P rate

SrcTest = (OUTPUT<=1) ? Src : Src.ChangeFPS(Src.FrameRateNumerator*2,Src.FrameRateDenominator)
# Select Progressive / Deinterlaced frame, based on IsCombedTIVTC detection on original source clip frame.
Result=ConditionalFilter(SrcTest, Deint, Prog, COMBDET,"=","true")

SrcOut = (!TITLE)?SrcTest:(OUTPUT<=1) ? Src.TSub("Source",TITNUM) : Src.TSub("Source DblRate via ChangeFPS, ie dupes",TITNUM).ChangeFPS(Src.FrameRateNumerator*2,Src.FrameRateDenominator)

Result = (!TITLE)?Result :(OUTPUT<=1) ? Result.TSub(String(OUTPUT,"%.0f) Result SingleRate"),TITNUM) : (OUTPUT==2) ? Result.TSub("2) Result DblRate (Progressive frames via ChangeFPS)",TITNUM)
        \ : Result.TSub("3) Result DblRate (Progressive frames via JohnFPS, ie MvTools2)",TITNUM)

(STACK) ? Stackhorizontal(SrcOut, Result) : Result

(PRE_FETCH>1) ? Prefetch(PRE_FETCH) : NOP  # I had problems using x64 and Prefetch [Access Violation], culprit was old IsCombedTIVTC, fixed via Pinterf version.

Return Last

#####################
# Stack Overhead Subtitle Text, with optional FrameNumber shown.
Function TSub(clip c,string Tit,Bool "ShowFrameNo",Int "Col"){
    c.BlankClip(height=20,Color=Default(Col,0))
    (Default(ShowFrameNo,False))?ScriptClip("""Subtitle(String(current_frame,"%.f] """+Tit+""""))"""):Trim(0,-1).Subtitle(Tit)
    Return StackVertical(c).AudioDubEx(c)
}
EDIT: Dont ,miss previous post where Spotless update to v1.03.
EDIT: Also, with above script I found that is better with ThSAD2=5000, rather than default 10000.
EDIT: Perhaps good guess for ThSAD2 would be 10,000 / RadT, so
RadT=2 then 5000 : RadT=6 then 1666 : RadT=10 then 1000 : RadT=20 then 500
__________________
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; 13th September 2020 at 14:43.
StainlessS is offline   Reply With Quote
Old 14th September 2020, 11:36   #17  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Metropolitan City of Milan, Italy
Posts: 1,414
I just tried SpotLess and it's absolutely Spot On xD
No, seriously, it's coming in handy as I'm cleaning the 1948 Olympics.
FranceBB is offline   Reply With Quote
Old 14th September 2020, 11:45   #18  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,132
Dont tell anybody your secret, you'll be able to ask for a pay rise
__________________
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 14th September 2020, 15:43   #19  |  Link
Frank62
Registered User
 
Join Date: Mar 2017
Location: Germany
Posts: 138
Also a big thank you to @StainlessS (and Didee), I am using it too, with a very dirty and scratchy source, and it works very well!
I agree to those who use it with truemotion=false.
Fast big things in the foreground give far less artefacts - I have no idea why, just tested.
Frank62 is offline   Reply With Quote
Old 14th September 2020, 23:37   #20  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,439
I decided to take SpotLessS (note my improved spelling) out for a spin, hoping that it might be a more modern alternative to RemoveDirt.

I am very encouraged by the initial trials and, if I can figure out how to tune it, it might just be a good replacement.

I did run into two problems with my "torture clip." First, SpotLessS is slow. I made no attempt to run it with multithreading enabled because some of the posts made it sound like that wasn't going to work. For me, getting it to work multi-threaded will be mandatory if I am to use it. I didn't want to waste time on that effort until I am first convinced that it is something I can really use.

The second issue was its tendency to remove far more "good things" than does RemoveDirt. Let me explain by referring to my torture clip.

Here is a single, fairly long play, from an early 1960s American football game, recorded on 24 fps B&W movie film. This is cut directly from the DVD that was supplied to me (i.e., it is as far up the food chain as I can go, since I do not have access to the film itself):

http://www.mediafire.com/file/fgtsy9...ip_02.mpg/file

This film was horribly damaged, and I spent a full day repairing it, mostly by hand, by masking in good video from adjacent frames to replace the huge chemical spots (they look like nitrate film deterioration, but this film seems too modern to have been nitrate). I was still left with lots of dirt to remove, and the RemoveDirt portion of my film restoration script did a really good job with that.

Here is the script I used to test SpotLessS:

Code:
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\MVTools\Latest Version\mvtools2.dll")       
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\MedianBlur2.dll")       
source = AVISource("e:\fs.avi").ConvertToYV12(interlaced=true).killaudio()
output = SpotLess(source)
#return output

Interleave(
\    source
\  , output
\ )
As I stepped through each frame using the Interleave code (which shows me the original frame followed immediately by the restored frame) I began to note that an awful lot of arms and legs were disappearing. Having the ball disappear in flight is something I have never been able to avoid with RemoveDirt, but arms and legs seldom disappear.

Then, with this particular clip, I noticed a huge number of hash marks were also disappearing. For those not familiar with American football, hash marks are the short lines on the field which are paced exactly one yards apart, using for spotting the ball for the next play. I have never seen these disappear in all the dozens of hours of football plays I've restored for a major sports film collector using my version of VideoFred's film restoration scripts to which I added RemoveDirt.

I'm hoping that both problems can be fixed by tweaking a few variables, but I am asking for just a few hints as to which variables I should focus on.

StainlessS, you may find this torture clip pretty useful because it has a LOT of things going on: motion in the frame, as well as horizontal camera motion; high contrast and low contrast dirt; massive dirt stains (some of which SpotLessS removes almost perfectly!!); and of course, "spots!!"
------------

[edit]
I'm having some success by massively reducing ThSAD2 (1000 instead of 10000). Chroma=false also helps a lot (source is B&W). BlkSz massively changes the results: 16 makes everything disappear, but 4 significantly degrades the spot removal. The sensitivity to block size is way more pronounced than I have ever seen with other MVTools2 scripts and may provide hints on what other things to tune.

[edit2]
OMG, the true motion variable is the secret: set that to false and really great things happen. Wow, wow, wow!

These are the variables that created magic:

Code:
output = SpotLess(source,ThSAD2=1000,RadT=2,Chroma=true,BlkSz=8,OLap=4,Tm=false)
Makes me wonder if I should experiment with that for other MVTools2 scripts I have.

I'll play around with this tomorrow when I'm fresher (age kills energy late in the day, I'm finding). However, as of right now, this may be the best AVISynth script or function I've used in the last year.

Way to go Mr. Lack of Stain.

Last edited by johnmeyer; 15th September 2020 at 03:01. Reason: clicked on "submit" instead of "preview" -- wasn't finished
johnmeyer is offline   Reply With Quote
Reply

Tags
denoise, despot, prefilter

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 11:40.


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