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 9th June 2010, 21:14   #221  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 1,852
Quote:
Originally Posted by Leinad4Mind View Post
johnmeyer, can u please upload, the "LimitedSupport_09Jan06B.dll" plugin, I can just find the 2005 version of it.
All the AVISynth DLLs needed for VideoFred's script are included in his download link posted at the beginning of this thread, including "LimitedSupport_09Jan06B.dll."

The only additional DLLs you will need to run my version of this script are the RemoveDirt DLL and also the multi-threaded version of AVISynth, if you want the extra speed that comes from multi-threading portions of this script, and if you have a multi-core CPU. Both those links are given in the changelog of my script in my post above.

BTW, I just noticed something in that before/after YouTube example I linked to in my previous post, and it is another testament to the brilliance of what VideoFred has done. Run the video full screen at 480p and then look at the side of the building in the lower left corner of the screen. In the before, you can't see anything, but in the after, you can see two murals on the side of the building the details of which remain steady and clear, despite the dirt and mold that comes and goes from frame to frame.

Last edited by johnmeyer; 9th June 2010 at 21:18. Reason: Added postscript shortly after initial posting
johnmeyer is offline   Reply With Quote
Old 9th June 2010, 21:29   #222  |  Link
Leinad4Mind
Please, DeInterlace me!
 
Leinad4Mind's Avatar
 
Join Date: Jan 2007
Location: Portugal, Porto
Posts: 83
Thks johnmeyer.

btw if anyone want's more than an Mdegrain3, like an MDegrain5, here it is, (in many cases, it's not really necessary):

Code:
#DENOISING PARAMETERS
#----------------------------------------------------------------------------------------------------------------------------
denoising_strength=600                     #denoising level of first denoiser: MVDegrain() 
block_size= 16                             #block size of MVDegrain
block_size_v= 16
block_over= 8                              #block overlapping of MVDegrainMulti()
dirt_strength=23                           #sets amount of dirt removal (big spots)
tm= true
pel_value= 2
shrp_value= 1
idx_value= 11
Code:
#DENOISING
#...................................................................................................................................................................
input_to_removedirt=stab.crop(CLeft,CTop,-CRight,-CBottom)
stabcrop=RemoveDirtMC(input_to_removedirt,dirt_strength,false)
super = stabcrop.MSuper(pel=2)
bvec1 = MAnalyse(super, isb = true,  delta = 1, blksize=block_size, overlap=block_over)
fvec1 = MAnalyse(super, isb = false, delta = 1, blksize=block_size, overlap=block_over)
bvec2 = MAnalyse(super, isb = true,  delta = 2, blksize=block_size, overlap=block_over)
fvec2 = MAnalyse(super, isb = false, delta = 2, blksize=block_size, overlap=block_over)
bvec3 = MAnalyse(super, isb = true,  delta = 3, blksize=block_size, overlap=block_over)
fvec3 = MAnalyse(super, isb = false, delta = 3, blksize=block_size, overlap=block_over)
bvec4 = MAnalyse(super, isb = true,  delta = 4, blksize=block_size, overlap=block_over)
fvec4 = MAnalyse(super, isb = false, delta = 4, blksize=block_size, overlap=block_over)
bvec5 = MAnalyse(super, isb = true,  delta = 5, blksize=block_size, overlap=block_over)
fvec5 = MAnalyse(super, isb = false, delta = 5, blksize=block_size, overlap=block_over)

#Use the second line below, and un-comment two lines above if you want to average more frames. Doesn't seem necessary for most work IMHO.
#denoised=stabcrop.MDegrain2(super, bvec1,fvec1,bvec2,fvec2,thSAD=denoising_strength).levels(0,gamma,255,0,255).tweak(sat=saturation).unsharpmask(PRE_sharp_ness,PRE_radi_us,0)
#denoised=stabcrop.MDegrain3(super, bvec1,fvec1,bvec2,fvec2,bvec3,fvec3,thSAD=denoising_strength).levels(0,gamma,255,0,255).tweak(sat=saturation).unsharpmask(PRE_sharp_ness,PRE_radi_us,0)

#Use this lines for MDegrain5 and activate ALL bvec and fvec above.
superDenoised=stabcrop.MDegrain3(super, bvec1,fvec1,bvec2,fvec2,bvec3,fvec3,thSAD=denoising_strength).levels(0,gamma,255,0,255).tweak(sat=saturation).unsharpmask(PRE_sharp_ness,PRE_radi_us,0)
denoised=stabcrop.MDegrain2(super, bvec4,fvec4,bvec5,fvec5,thSAD=denoising_strength).levels(0,gamma,255,0,255).tweak(sat=saturation).unsharpmask(PRE_sharp_ness,PRE_radi_us,0)
 \           .Merge(superDenoised, 0.436) # correct weightings (hopefully)
Best Regards
__________________
Who am I?! I'm GOD... 8for it... father of my godchilds.
Leinad4Mind is offline   Reply With Quote
Old 9th June 2010, 22:55   #223  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 1,852
Quote:
Originally Posted by Leinad4Mind View Post
btw if anyone want's more than an Mdegrain3, like an MDegrain5, here it is, (in many cases, it's not really necessary):
In my quest for a faster script, I did a lot of testing using just two "before" and two "after" MAnalyze vectors. I couldn't tell any difference. However, this isn't to say that there might be. Have you found any substantial improvement in using the extra vectors, and if so, what did they look like, and in what circumstances did they occur?
johnmeyer is offline   Reply With Quote
Old 9th June 2010, 23:24   #224  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 1,852
Just a quick update.

As I work my way through 100 reels of film, I keep experimenting. I have found that the main reason that VideoFred's script does a better job bringing out details in scenes containing lots of "structure" is due mostly to the LimitedSharpenFaster function. I removed this because it takes my script from 15 fps to about 9 fps. However, I have added it back in as an option and am occasionally using it on certain reels. As time permits I will see if I can get the LimitedSharpen MOD version to run faster under MT. I did spend some time with this yesterday, but wasn't able to get it to run any faster. There is also a similar sharpening script that I think is called "SeeSaw" or something like that. I may experiment with that.
johnmeyer is offline   Reply With Quote
Old 9th June 2010, 23:37   #225  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,375
Quote:
Originally Posted by Leinad4Mind View Post
Code:
superDenoised=stabcrop.MDegrain3(super, bvec1,fvec1,bvec2,fvec2,bvec3,fvec3,thSAD=denoising_strength).levels(0,gamma,255,0,255).tweak(sat=saturation).unsharpmask(PRE_sharp_ness,PRE_radi_us,0)
denoised=stabcrop.MDegrain2(super, bvec4,fvec4,bvec5,fvec5,thSAD=denoising_strength).levels(0,gamma,255,0,255).tweak(sat=saturation).unsharpmask(PRE_sharp_ness,PRE_radi_us,0)
 \           .Merge(superDenoised, 0.436) # correct weightings (hopefully)
Is it valid to use vectors of delta=4 or 5 with MDegrain2?
Even if it is, how did you derive the merge weight?
I don't think it's possible to get the right final weighting for both the centre frame and the outermost ones at the same time.
Gavino is offline   Reply With Quote
Old 10th June 2010, 02:19   #226  |  Link
Leinad4Mind
Please, DeInterlace me!
 
Leinad4Mind's Avatar
 
Join Date: Jan 2007
Location: Portugal, Porto
Posts: 83
Quote:
Originally Posted by Gavino View Post
Is it valid to use vectors of delta=4 or 5 with MDegrain2?
Even if it is, how did you derive the merge weight?
I don't think it's possible to get the right final weighting for both the centre frame and the outermost ones at the same time.
Yes it is. How did I ? I didn't. Didée did.

Check this: http://forum.doom9.org/showthread.php?p=1138514

Btw, I have been working around with the script, but for restore very old dvd animation. Soon I will post the "new" script and my results.

best regards
__________________
Who am I?! I'm GOD... 8for it... father of my godchilds.
Leinad4Mind is offline   Reply With Quote
Old 10th June 2010, 04:03   #227  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,390
@Gavino: yes, mdegrainX allows to use vectors with such deltas. And, yes, there is no "fully correct" way to make that particular averaging.


@ Leinad4Mind - you're linking to the wrong thread/post/script. That one is TGMC, and the averaging used in there is quite a bit different.

What you would have wanted to link is this here, most probably.
But again - that averaging is a reasonable approximation, but not-at-all mathematically exact (since that's impossible.).

In any case, you seem to have reversed the weighting: you've small weight for the 3-frame-clip, and bigger weight for the 2-frame-clip. It should be exactly the other way round.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 10th June 2010, 07:14   #228  |  Link
Leinad4Mind
Please, DeInterlace me!
 
Leinad4Mind's Avatar
 
Join Date: Jan 2007
Location: Portugal, Porto
Posts: 83
I mean here: http://forum.doom9.org/showthread.php?p=1138690 ^^'

And I think I've fixed the weighting ^^'

Code:
#Use this lines for MDegrain5 and activate ALL bvec and fvec above.
superDenoised=stabcrop.MDegrain3(super, bvec1,fvec1,bvec2,fvec2,bvec3,fvec3,thSAD=denoising_strength).levels(0,gamma,255,0,255).tweak(sat=saturation)#.unsharpmask(PRE_sharp_ness,PRE_radi_us,0)
denoised=superDenoised.MDegrain2(super, bvec4,fvec4,bvec5,fvec5,thSAD=denoising_strength)
\           .Merge(superDenoised, 0.436) # correct weightings (hopefully)
Right Didée?

I have made my own modded version, aim for old and ugly animation xD

Here it is the result:Anime-Restoration
__________________
Who am I?! I'm GOD... 8for it... father of my godchilds.

Last edited by Leinad4Mind; 10th June 2010 at 08:05.
Leinad4Mind is offline   Reply With Quote
Old 10th June 2010, 09:18   #229  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,375
Quote:
Originally Posted by Leinad4Mind View Post
I mean here: http://forum.doom9.org/showthread.php?p=1138690 ^^'
And I think I've fixed the weighting ^^'
Right - I see how that can work, as MDegrain2 is applied to the result of MDegrain3, giving the central frame the same weight as its neighbours. But I think the merge weight should be 5/11 = 0.455.
Gavino is offline   Reply With Quote
Old 10th June 2010, 12:03   #230  |  Link
Leinad4Mind
Please, DeInterlace me!
 
Leinad4Mind's Avatar
 
Join Date: Jan 2007
Location: Portugal, Porto
Posts: 83
Quote:
Originally Posted by Gavino View Post
Right - I see how that can work, as MDegrain2 is applied to the result of MDegrain3, giving the central frame the same weight as its neighbours. But I think the merge weight should be 5/11 = 0.455.
yeah, u're right I will put then "0.4545". thks in advance
__________________
Who am I?! I'm GOD... 8for it... father of my godchilds.
Leinad4Mind is offline   Reply With Quote
Old 10th June 2010, 17:58   #231  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,375
John, firstly well done for your work on the script.
Quote:
Originally Posted by johnmeyer View Post
Code:
#  13. Added killaudio() statement to prevent lockups when using SetMTMode().
Have you experienced these lockups yourself, or can you provide links to evidence?
This sounds like an urban myth to me since as far as I know SetMTMode does not touch the audio in any way and it continues to run single-threaded.
Gavino is offline   Reply With Quote
Old 10th June 2010, 19:38   #232  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 1,852
Quote:
Originally Posted by Gavino View Post
Have you experienced these lockups yourself, or can you provide links to evidence?
This sounds like an urban myth to me since as far as I know SetMTMode does not touch the audio in any way and it continues to run single-threaded.
Yes, I experienced myself:

http://forum.doom9.org/showthread.ph...42#post1345342

You'll have to read several posts down from this one to see where the killaudio() command was suggested as a way to stop crashes when using setmtmode() with MVTools2. Not only did it work, but when I have forgotten to include it in other scripts, I have experienced crashes until I remember to add it.
johnmeyer is offline   Reply With Quote
Old 10th June 2010, 21:31   #233  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,390
I can't confirm that urban myth. It seems that SetMTmode + MVTools really has a nasty tendency to crash. From what I experienced so far, it seems related to SetMemoryMax. Rule of thumb: when SMM is <1GB (32bit Avisynth) resp. <2GB (64bit Avisynth), then usually all is good. When going beyond 1GB (32) / 2GB (64bit), I can literally sit there and wait for the crash, it won't take long.

I tried the KillAudio() thingy, but it doesn't change anything for me. (Well, how should it? With Mpeg2source, there is no audio to start with...)
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 10th June 2010, 22:00   #234  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,375
Quote:
Originally Posted by Didée View Post
I tried the KillAudio() thingy, but it doesn't change anything for me. (Well, how should it? With Mpeg2source, there is no audio to start with...)
LOL - a good one!

Your experience shows there is definitely some memory-related problem with SetMTMode+MVTools, even when there is no audio in sight (or in earshot). I suspect adding KillAudio simply changes the memory location of other filters and the real problem lies elsewhere.

In the script johnmeyer referenced that originally had a problem, killaudio was already present and simply moving it made the problem (appear to) go away. So it is not related to the presence or absence of an audio-processing execution path. Problems that come and go with random script changes are nearly always due to memory corruption of some kind.

Still, if KillAudio makes a particular script work (and you don't want the audio anyway), then you might as well keep it in...
Gavino is offline   Reply With Quote
Old 17th June 2010, 16:44   #235  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Hollola, Finland
Posts: 4,298
Code:
# based on videoFred's script and johnmeyer's modification of it
# PLEASE NOTE THAT THIS FUNCTION IS NOT SMART, IT IS JUST SOME THINGS POURED TOGETHER!
# THE THREAD http://forum.doom9.org/showthread.php?t=144271 CONTAINS THE ORIGINAL SCRIPT



function RestoreOldFilm (clip film, string "result", int "trim_begin", float "play_speed", float "saturation", float "gamma",
\                       int "blue", int "red", int "black_level", int "white_level", int "output_black", int "output_white",
\                       int "CLeft", int "CTop", int "CRight", int "CBottom", int "W", int "H", int "bord_left", int "bord_top",
\                       int "bord_right", int "bord_bot", int "in_bord_left", int "in_bord_top", int "in_bord_right", int "in_bord_bot",
\                       int "maxstabH", int "maxstabV", int "range", float "trust", int "est_left", int "est_top", int "est_right", int "est_bottom",
\                       float "est_cont", int "mirror", int "denoising_strength", int "block_size", int "block_size_v", int "block_over",
\                       int "thscd1", int "thscd2", int "rfilter", int "search", int "searchparam", int "lambda", int "pnew", int "plevel",
\                       int "lsad", int "badsad", int "dirt_strength", int "smode", int "lsfstrength", int "X", int "X2",
\                       bool "stabilize", bool "denoise", bool "sharpen", bool "despot")
                       
{
result=default(result, "resultS3")                                             
trim_begin=default(trim_begin, 0)
play_speed=default(play_speed, 18)
saturation=default(saturation, 1.2)
gamma=default(gamma, 1.2)
blue=default(blue, -0)
red=default(red, -0)
black_level=default(black_level, 0)
white_level=default(white_level, 255)
output_black=default(output_black, 0)
output_white=default(output_white, 255)
CLeft=default(CLeft, 0)
CTop=default(CTop, 0)
CRight=default(CRight, 0)
CBottom=default(CBottom, 0)
W=default(W, 720)
H=default(H, 576)
bord_left=default(bord_left, 0)
bord_right=default(bord_right, 0)
bord_top=default(bord_top, 0)
bord_bot=default(bord_bot, 0)
range=default(range, 3)
trust=default(trust, 4.0)
in_bord_left=default(in_bord_left, 0)
in_bord_right=default(in_bord_right, 0)
in_bord_top=default(in_bord_top, 0)
in_bord_bot=default(in_bord_bot, 0)
maxstabH=default(maxstabH, 20)
maxstabV=default(maxstabV, 20)
est_left=default(est_left, 0)
est_right=default(est_right, 0)
est_top=default(est_top, 0)
est_bottom=default(est_bottom, 0)
est_cont=default(est_cont, 1.3)
mirror=default(mirror, 0)
denoising_strength=default(denoising_strength, 600)
block_size=default(block_size, 16)
block_size_v=default(block_size_v, block_size)
block_over=default(block_over, block_size/2)
thscd1=default(thscd1, 400)
thscd2=default(thscd2, 130)
rfilter=default(rfilter, 4)
search=default(search, 5)
searchparam=default(searchparam, 8)
lambda= default(lambda, 100*block_size*block_size/64)
pnew= default(pnew, 25)
plevel= default(plevel, 0)
lsad= default(lsad, 400*block_size*block_size/64)
badsad=default(badsad, 10000)
dirt_strength=default(dirt_strength, 23)
smode=default(smode, 5)
lsfstrength=default(lsfstrength, 100)
X=default(X, 4)
X2=default(X2, 2)
stabilize=default(stabilize, true)
sharpen=default(sharpen, true)
denoise=default(denoise, true)
despot=default(despot, true)


source1= film.killaudio().assumefps(play_speed).trim(trim_begin,0).converttoYV12()
cropped_source=source1.crop(in_bord_left,in_bord_top,-in_bord_right,-in_bord_bot)

stab_reference = (stabilize == true) ? cropped_source.crop(est_left,est_top,-est_right,-est_bottom).mt_binarize(threshold=round(80/est_cont),upper=true,U=-128,V=-128) : cropped_source
mdata          = (stabilize == true) ? DePanEstimate(stab_reference,trust=trust,dxmax=maxstabH,dymax=maxstabV,range=range) : NOP()
stab           = (stabilize == true) ? DePanStabilize(cropped_source,data=mdata,info=false,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mirror=mirror) : cropped_source

WS = width(stab)
HS = height(stab)
stab4          = (stabilize == true) ? stab.addborders(10,10,10,10,$B1B1B1).Lanczos4Resize(WS,HS) : cropped_source.addborders(10,10,10,10,$B1B1B1).Lanczos4Resize(WS,HS)

spot           = (despot == true) ? RemoveSpots(stab) : stab

input_to_removedirt = (denoise == true) ? spot.crop(CLeft,CTop,-CRight,-CBottom) : NOP()
stabcrop            = (denoise == true) ? RemoveDirtMC(input_to_removedirt,dirt_strength,false) : NOP()
super               = (denoise == true) ? stabcrop.MSuper(pel=2,rfilter=rfilter) : NOP()
bvec1               = (denoise == true) ? MAnalyse(super, isb = true,  delta = 1, blksize=block_size, overlap=block_over, search=search, searchparam=searchparam, truemotion=false, global=true, lambda=lambda, pnew=pnew, plevel=plevel, lsad=lsad, badsad=badsad) : NOP()
fvec1               = (denoise == true) ? MAnalyse(super, isb = false, delta = 1, blksize=block_size, overlap=block_over, search=search, searchparam=searchparam, truemotion=false, global=true, lambda=lambda, pnew=pnew, plevel=plevel, lsad=lsad, badsad=badsad) : NOP()
bvec2               = (denoise == true) ? MAnalyse(super, isb = true,  delta = 2, blksize=block_size, overlap=block_over, search=search, searchparam=searchparam, truemotion=false, global=true, lambda=lambda, pnew=pnew, plevel=plevel, lsad=lsad, badsad=badsad) : NOP()
fvec2               = (denoise == true) ? MAnalyse(super, isb = false, delta = 2, blksize=block_size, overlap=block_over, search=search, searchparam=searchparam, truemotion=false, global=true, lambda=lambda, pnew=pnew, plevel=plevel, lsad=lsad, badsad=badsad) : NOP()
#bvec3              = (denoise == true) ? MAnalyse(super, isb = true,  delta = 3, blksize=block_size, overlap=block_over, search=search, searchparam=searchparam, truemotion=false, global=true, lambda=lambda, pnew=pnew, plevel=plevel, lsad=lsad, badsad=badsad) : NOP()
#fvec3              = (denoise == true) ? MAnalyse(super, isb = false, delta = 3, blksize=block_size, overlap=block_over, search=search, searchparam=searchparam, truemotion=false, global=true, lambda=lambda, pnew=pnew, plevel=plevel, lsad=lsad, badsad=badsad) : NOP()
denoised            = (denoise == true) ? stabcrop.MDegrain2(super,bvec1,fvec1,bvec2,fvec2,thSAD=denoising_strength,thscd1=thscd1,thscd2=thscd2).levels(0,gamma,255,0,255).tweak(sat=saturation) : spot

sharp1              = (sharpen == true) ? denoised.LSFMod(defaults="slow",smode=smode,strength=lsfstrength) : NOP()
PreBorderFrame      = (sharpen == true) ? sharp1.Lanczos4Resize(W - bord_left - in_bord_left - bord_right - in_bord_right, H - bord_top - in_bord_top - bord_bot - in_bord_bot) : denoised

#RESULT1: AUTOLEVELS,AUTOWHITE
#......................................................................................................................................................................

result1= PreBorderFrame.coloryuv(autowhite=true).addborders(X,0,0,0,$FFFFFF).addborders(0,0,X2,0,$000000).autolevels(filterRadius=2).crop(X,0,-X2,-0).addborders(bord_left+in_bord_left, bord_top+in_bord_top, bord_right+in_bord_right, bord_bot+in_bord_bot)

#RESULT2: MANUAL LEVELS, AUTOWHITE
#......................................................................................................................................................................
result2= PreBorderFrame.levels(black_level,gamma,white_level,0,255).coloryuv(autowhite=true).addborders(bord_left+in_bord_left, bord_top+in_bord_top, bord_right+in_bord_right, bord_bot+in_bord_bot)

#RESULT3: AUTOLEVELS, MANUAL COLOR CORRECTIONS
#.....................................................................................................................................................................
result3= PreBorderFrame.coloryuv(off_U=blue,off_V=red).addborders(X,0,0,0,$FFFFFF).addborders(0,0,X2,0,$000000).autolevels(filterRadius=2).crop(X,0,-X2,-0).addborders(bord_left+in_bord_left, bord_top+in_bord_top, bord_right+in_bord_right, bord_bot+in_bord_bot)

#RESULT4: MANUAL LEVELS, MANUAL COLOR CORRECTIONS
#.....................................................................................................................................................................
result4= PreBorderFrame.coloryuv(off_U=blue,off_V=red).levels(black_level,gamma,white_level,0,255).addborders(bord_left+in_bord_left, bord_top+in_bord_top, bord_right+in_bord_right, bord_bot+in_bord_bot)

result5= overlay(source1,stab_reference,x=est_left,y=est_top).addborders(2,2,2,2,$FFFFFF).Lanczos4Resize(WS,HS)

#PARAMETERS FOR THE COMPARISONS
#.....................................................................................................................................................................
W2= W+bord_left+bord_right
H2= H+bord_top+bord_bot
source4=Lanczos4Resize(source1,W2,H2)


#COMPARISONS: ORIGINAL VS RESULTS
#......................................................................................................................................................................
resultS1= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result1,"autolevels, autowhite",size=28,align=2))
resultS2= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result2,"autowhite, manual levels correction",size=28,align=2))
resultS3= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result3,"autolevels, manual color correction",size=28,align=2))
resultS4= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result4,"manual colors and levels correction",size=28,align=2))
resultS5= stackhorizontal(subtitle(result5,"baseclip for stabiliser -only the B/W clip is used",size=32,align=2),subtitle(stab4,"test stabiliser: dx=horizontal, dy=vertical",size=32,align=5))


Eval(result)

}

# END SCRIPT, BEGIN FUNCTIONS
#=================================================================================================================================


#REMOVE DIRT FUNCTION
#......................................................................................................................................................................
function RemoveDirt(clip input, int limit, bool _grey)
{
  clensed=input.Clense(grey=_grey, cache=4)
  alt=input.RemoveGrain(2)
  return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=6,cthreshold=8, gmthreshold=40,dist=3,dmode=2,debug=false,noise=limit,noisy=4, grey=_grey)

  # Alternative settings
  # return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=4,cthreshold=6, gmthreshold=40,dist=1,dmode=2,debug=false,noise=limit,noisy=12,grey=_grey,show=true)
  # return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=6,cthreshold=8, gmthreshold=40,dist=3,tolerance= 12,dmode=2,debug=false,noise=limit,noisy=12,grey=_grey,show=false)
}

function RemoveDirtMC(clip,int limit, bool "_grey", int "block_size", int "block_over", int "thscd1", int "rfilter", int "search", int "searchparam", int "lambda", int "pnew", int "plevel", int "lsad")
{
  _grey=default(_grey, false)
  limit = default(limit,6)
  i=MSuper(clip,pel=2,rfilter=rfilter)
  bvec = MAnalyse(i,isb=false, blksize=block_size, overlap=block_over, delta=1, search=search, searchparam=searchparam, truemotion=false, global=true, lambda=lambda, pnew=pnew, plevel=plevel, lsad=lsad, badsad=500)
  fvec = MAnalyse(i,isb=true, blksize=block_size, overlap=block_over, delta=1, search=search, searchparam=searchparam, truemotion=false, global=true, lambda=lambda, pnew=pnew, plevel=plevel, lsad=lsad, badsad=500)
  backw = MFlow(clip,i,bvec,thscd1=thscd1)
  forw  = MFlow(clip,i,fvec,thscd1=thscd1)
  clp=interleave(backw,clip,forw)
  clp=clp.RemoveDirt(limit,_grey)
  clp=clp.SelectEvery(3,1)
  return clp
}

function Removespots (clip i, int "ml", int "thscd1", int "rfilter", int "block_size", int "block_over", int "search", int "searchparam", int "lambda", int "pnew", int "plevel", int "lsad", int "badsad")
{
prefilt=i.DeGrainMedian(mode=3) # prefiltered for better motion analysis

 #analyse and compensate motion forward and backward (to current frame)
ml=default(ml, 100)     # mask scale
thscd1=default(thscd1, 400) # scene change

super=i.MSuper(pel=2,rfilter=rfilter) # super clip
superprefilt=prefilt.MSuper(pel=2,rfilter=rfilter) # super filtered clip

vf = superprefilt.MAnalyse(isb=false,blksize=block_size,overlap=block_over,search=search, searchparam=searchparam, truemotion=false, global=true, lambda=lambda, pnew=pnew, plevel=plevel, lsad=lsad, badsad=badsad) # forward vectors 
cf = i.MFlow(super, vf, thscd1 = thscd1) # previous compensated forward
sadf = i.MMask(vf, ml=ml,kind=1,gamma=1, thscd1 = thscd1) # forward SAD mask
msadf=sadf.MT_Binarize() # binary inverted forward SAD mask

vb = superprefilt.MAnalyse(isb=true,blksize=block_size,overlap=block_over,search=search, searchparam=searchparam, truemotion=false, global=true, lambda=lambda, pnew=pnew, plevel=plevel, lsad=lsad, badsad=badsad)  # backward vectors 
cb = i.MFlow(super, vb, thscd1 = thscd1) # next compensated backward 
sadb = i.MMask(vb, ml=ml, gamma=1, kind=1, thscd1 = thscd1) # backward SAD mask
msadb = sadb.MT_Binarize() # binary inverted backward SAD mask

msad = MT_Logic(msadf,msadb,"or") # combined inverted SAD mask
msad = msad.MT_Expand() # expanded inverted SAD mask
msadi = Interleave(msad, msad, msad) # interleaved 3-frame inverted SAD mask
 #This mask is high (255) where at least one motion estimation is good, 
 #so these areas will be protected

Interleave(cf,i,cb) # interleave forward compensated, source, and backward compensated

DeSpot(p1=30,p2=12,pwidth=800,pheight=600,mthres=20,merode=33,\
   sign=0,show=0,seg=0,color=true,motpn=true, extmask=msadi)

Eval("SelectEvery(3,1)")
}
Here's my hack which I promised to post. The structure of the function is very stupid, no checks whatsoever. Things borrowed, stolen and pulled out of a hat No warranty, that is..hope someone will tweak and enhance it to be actually useful to anyone else but me. Gavino's GScript could do it some good, at least.
__________________
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 30th June 2010, 10:21   #236  |  Link
videoFred
Registered User
 
videoFred's Avatar
 
Join Date: Dec 2004
Location: Gent, Flanders, Belgium, Europe, Earth, Milky Way,Universe
Posts: 583
Script update

I am working on an improved script.

It looks like RemoveDirtMC() followed by MVDegrainMulti() gives realy spectacular results.
With special thanks to JohnMeyer for pionting me to RemoveDirtMC.

I have a few questions:

1) Who has made RemoveDirtMC() and what is the difference with the original RemoveDirt()?

2) Several step sharpening (big radius first) is absolutely the way to go for maximum quality.
But, from a pure technical view, should I apply sharpening before or after dirt removing and degraining?

3) The use of MT. I must place SetMTMode(5) on top of the script, if I understand it good. But then, where to place SetMTMode(2)?

Will RemoveDirtMC() has benefit of this? But MVDegrainMulti() comes after RemovedirtMC(). And as far as I know MVDegrainMulti() is multi core allready.

Sunny greetings from Belgium, (it's hot here now )

Fred.
videoFred is offline   Reply With Quote
Old 30th June 2010, 12:12   #237  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,390
Quote:
Originally Posted by videoFred View Post
1) Who has made RemoveDirtMC()
That's easy. (But I didn't remember, either.)

Search forum
-> search term "RemoveDirtMC"
--> show results as posts
---> sort results ascending

This will (should) find the first-ever mentioning of the search term on this board.

Here it is.


Quote:
and what is the difference with the original RemoveDirt()?
Obviously, the usage of motion compensation.


Quote:
But, from a pure technical view, should I apply sharpening before or after dirt removing and degraining?
From a technical view, it should be done either before, or after, or both.
(One can argue like this or like that, but there's not really any technical imperative.)


Quote:
But then, where to place SetMTMode(2)?
I say nothing. Whenever I "assume" something about Avisynth multithreading, I'm told that i got it all wrong.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 30th June 2010, 13:17   #238  |  Link
videoFred
Registered User
 
videoFred's Avatar
 
Join Date: Dec 2004
Location: Gent, Flanders, Belgium, Europe, Earth, Milky Way,Universe
Posts: 583
Quote:
Originally Posted by Didée View Post
Thank you!

Quote:
Obviously, the usage of motion compensation.
But of cource. Next time I will read a script before asking anything .

Quote:
From a technical view, it should be done either before, or after, or both.
Then it will be the videoFred approach: by eye

Quote:
I say nothing. Whenever I "assume" something about Avisynth multithreading, I'm told that i got it all wrong.
The same approach then.

Fred.
videoFred is offline   Reply With Quote
Old 30th June 2010, 15:08   #239  |  Link
Undead Sega
Registered User
 
Join Date: Oct 2007
Posts: 707
Dont mind me intruding (hahaha) but I would like to ask, how are you guys transfering your 8mm films to a digital format?
Undead Sega is offline   Reply With Quote
Old 30th June 2010, 15:11   #240  |  Link
videoFred
Registered User
 
videoFred's Avatar
 
Join Date: Dec 2004
Location: Gent, Flanders, Belgium, Europe, Earth, Milky Way,Universe
Posts: 583
Quote:
Originally Posted by Undead Sega View Post
how are you guys transfering your 8mm films to a digital format?
My signature

Fred.
videoFred is offline   Reply With Quote
Reply

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 04:24.


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