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. |
19th June 2011, 21:53 | #1 | Link |
Registered User
Join Date: Apr 2011
Posts: 9
|
HQDegrain
Hi all, I made this little degrain filter. I hope some of you will find it useful. If you have any kind of feedback, please do let me know what you think about it.
Code:
###################################################################### # # ~HQDegrain v0.9.2 by Alek93j~ 29/06/2011 # # Required MVtools2.dll http://avisynth.org.ru/mvtools/mvtools2.html # ttempsmooth.dll http://avisynth.org.ru/docs/english/...tempSmooth.htm # mt_masktools-25.dll http://manao4.free.fr/masktools-v2.0a48.zip # blockbuster.dll http://kvcd.net/sansgrip/avisynth/ # removegrain.dll http://avisynth.org/mediawiki/Removegrain # # ~Syntax~ ################################################################################## # # # It doesn't work perfectely with sudden luma changes such as fades, so it # # is best not to filter those parts. # # -Example of a Backup of a NTSC DvD- # # MPEG2Source("C:\blabla.d2v") # ivtc() (your prefer ivtc ectr) # A=hqdegrain() (Clip normally processed) # B=ttempsmoothf(maxr=7,strength=5,lthresh=3,cthresh=4) (or your prefer denoise for clean fade) # B.Trim(0,215)+A.Trim(216,31464) # ########################################################################### Function HQDegrain(clip clp,int"Degrain",int"limit",string"preset",bool"HQ",\ int"maxr",int"strength",int"lthresh",int"cthresh",\ clip"PreNoise",int"BkSize",bool"noise",bool"lmask",\ int"Blk",int"PEL",int"DCT",int"Overlap",\ int "thSAD", int "thSADC",int "thSCD1", int "thSCD2") { #Presets available "Fast" - "Slow" Preset=Default(Preset,"Slow") pset=(Preset=="Fast") ? 0 : 1 #MDegrain Strength Degrain = Default( Degrain , Select(pset,1,2)) # Means how many frame should be analyzed for a better result, 3 doesn't help much. limit = Default( limit , 255 ) # limit of mvdegrain. (255 mean no limits) #ttempsmoothf Strength HQ = Default( HQ , Select(pset,false,true)) # Reduce artefact... maxr = Default( maxr , Select(pset,3,5)) strength= Default( strength, Select(pset,3,4)) lthresh = Default( lthresh , Select(pset,2,3)) cthresh = Default( cthresh , Select(pset,3,4)) #Noise Filter Noise = Default( Noise , true ) BkSize = Default( BkSize , 8 ) lmask = Default( lmask , Select(pset,false,true)) #if lmask is true, noise will not be added in the parts of the image with high luma values, because generally there is no need to filter them. #Motion Vector Analyse Blk = Default( Blk , 8 ) # Use 16/for 1080p - 8/for 720p - 4/for 480p to avoid unnecessary slowdowns. PEL = Default( PEL , 2 ) DCT = Default( DCT , 0 ) OPS = Blk/2 Overlap = Default( Overlap , Select(pset,0,OPS)) #Threshold Setting thSAD = Default( thSAD , 180 ) # Lower values will reduce artefacts for bad motion vectors, but they will also have a lighter denoising effect. For animated sources, 120 seems to be a good setting to start with. thSADC = Default( thSADC , thSAD ) thSCD1 = Default( thSCD1 , 400 ) thSCD2 = Default( thSCD2 , 102 ) #Processing input = clp mask = clp.invert().levels(82,1,155,0,255,coring=false).Removegrain(12) nse = defined(PreNoise) ? PreNoise \: (Noise==true) ? clp.blockbuster(method="noise",Block_size=BkSize) : clp clp = (Noise==false) ? clp : (lmask==true) ? mt_merge(clp,nse,mask) : nse sup = clp.Msuper(hpad=Blk,vpad=Blk,PEL=PEL,levels=0) BV1 = MAnalyse(sup,isb=true ,truemotion=true,delta=1,blksize=Blk,blksizeV=Blk,DCT=DCT,overlap=Overlap) FV1 = MAnalyse(sup,isb=false,truemotion=true,delta=1,blksize=Blk,blksizeV=Blk,DCT=DCT,overlap=Overlap) BV2 = (Degrain>=2) ? MAnalyse(sup,isb=true ,truemotion=true,delta=2,blksize=Blk,blksizeV=Blk,DCT=DCT,overlap=Overlap) : Blackness () FV2 = (Degrain>=2) ? MAnalyse(sup,isb=false,truemotion=true,delta=2,blksize=Blk,blksizeV=Blk,DCT=DCT,overlap=Overlap) : Blackness () BV3 = (Degrain==3) ? MAnalyse(sup,isb=true ,truemotion=true,delta=3,blksize=Blk,blksizeV=Blk,DCT=DCT,overlap=Overlap) : Blackness () FV3 = (Degrain==3) ? MAnalyse(sup,isb=false,truemotion=true,delta=3,blksize=Blk,blksizeV=Blk,DCT=DCT,overlap=Overlap) : Blackness () clp = (degrain==1) ? clp.MDegrain1(sup,BV1,FV1, thSAD=thSAD,thSADC=thSADC,thSCD1=thSCD1,thSCD2=thSCD2,limit=limit): \ (degrain==2) ? clp.MDegrain2(sup,BV1,FV1,BV2,FV2, thSAD=thSAD,thSADC=thSADC,thSCD1=thSCD1,thSCD2=thSCD2,limit=limit): \ clp.MDegrain3(sup,BV1,FV1,BV2,FV2,BV3,FV3,thSAD=thSAD,thSADC=thSADC,thSCD1=thSCD1,thSCD2=thSCD2,limit=limit) Diff1 = mt_makediff(input,clp,U=3,V=3) clp2 = clp.ttempsmoothf(maxr=maxr,strength=strength,lthresh=lthresh,cthresh=cthresh) Diff2 = mt_makediff(input,clp2,U=3,V=3) lutxy = mt_lutxy(Diff1,Diff2,"x 128 - abs y 128 - abs < x y ?") output = (HQ==true) ? Input.mt_makediff(lutxy,U=3,V=3) : clp2 output } Last edited by Alek93j; 29th June 2011 at 21:53. Reason: New Version |
21st June 2011, 11:13 | #3 | Link | |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
Welcome on D9, Alek93j.
Quote:
Code:
sup = clp.Msuper(hpad=Blk,vpad=Blk,PEL=PEL,levels=0) sup2= clp.Msuper(hpad=Blk,vpad=Blk,PEL=PEL,levels=1) Also, it seems there is some confusion about chroma processing: Both the MDegrain's and ttempsmoothF *do* process chroma. But when "HQ=true" (default), then all chroma processing is thrown away because of the mt_makediff's and the mt_lutxy's. You should decide whether chroma shall be processed or not. If not, then you can get better speed by setting "plane=0" in MDegrainX, and by setting "cthresh=1" in ttempsmooth. If chroma should be processed, then you need to add ",U=3,V=3" in all mt_makediff and all mt_lutxy. Seems to be a nice filter for baby grain. For real men's grain, it's a bit on the weak side. Funny trivia: It's a "degrain" filter, and the very-first internal operation is to add more grain. (Blockbuster) Judging visually, the results seem pretty okay.
__________________
- 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!) |
|
21st June 2011, 13:10 | #4 | Link | |
TV Guy
Join Date: Jun 2011
Posts: 46
|
Am looking for a Nice script to clean some 16mm Kine's!
Quote:
Will let you know If i get further, as Im keen for a script that can clean 16mm Kine's, even if its only a first pass before something else. Sick of pixilated movement! Last edited by Gerry62; 21st June 2011 at 13:21. |
|
21st June 2011, 13:19 | #5 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
What ttempsmoothf errors? The script is technically correct, there should not occur any errors as long as you respect the valid parameter ranges for ttempsmooth's parameters: maxr=[1...7], strength=[1...8], lthresh/cthresh=[1...256]
__________________
- 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!) |
21st June 2011, 13:24 | #6 | Link | |
TV Guy
Join Date: Jun 2011
Posts: 46
|
Quote:
But the user (IE Me) is a little green, but as keen as mustard to get it to work! Spent all day on Killer() and failed! Must be where Im placing the ttempsmooth.dll. And over the last few weeks ive been reading some of your posts Didee, If I could create a , 'I Am not worthy' script, it would be now, you are a god of the synth~! and please disregard my amuter efforts in getting things to work. Your a champ alek93j, love your efforts, will love it more when Ive seen it work! Last edited by Gerry62; 21st June 2011 at 13:28. |
|
21st June 2011, 13:35 | #7 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
You still didn't state the exact error. If it is "There is no function named 'ttempsmoothf' ", then you need to LoadPlugin() the ttempsmooth.dll ...
__________________
- 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!) |
21st June 2011, 14:34 | #8 | Link |
TV Guy
Join Date: Jun 2011
Posts: 46
|
Wow, how stupid am I!
I had the x64 DLL in my plugins directory, hence the error's, Have now put the correct 32bit dll and it's working fine, the defult setup is not as 'strong' as id like the 16mm kino's are 'grain city'. which makes any restoration very difficult as when you clean the grains all movement looks very 'gritty' and pixelated to hell. Will spend some time mucking about with the settings and see how this new function works with my dire material! |
21st June 2011, 21:46 | #9 | Link | ||||
Registered User
Join Date: Apr 2011
Posts: 9
|
thanks for welcome
thanks for reminding me, I had forgotten about it. Quote:
Quote:
original hq false hq true I admit that I copied the masktool part from your script "temporal degrain", beacuse I got the exact results which I wanted, and I was stupid to not specify it from the beginning, and the main reason I posted the filter is to get help for that part, so, can you help me to get those results in the right way, or, if is it possible, also better? I would be grateful to you. Quote:
Blockbuster adds noise, doesn't it? I created this function for "restore" the grain affected by macroblocking etc. caused by a bad compression, they aren't really pleasant during the reproduction. This function also removes a little part of grain extra (for example, in the bright parts of the image).My idea was to fill these empty parts with blockbuster and then to work with MDegrain: it would have switched a part of noise for the grain e it would have removed it, but not completely. And, to finish, make everything homogeneous with ttempsmooth, which is my favourite smoother, as you can see in the screens that I posted first. Quote:
|
||||
23rd June 2011, 09:48 | #11 | Link | |
--preset WTF!
Join Date: Feb 2009
Posts: 86
|
Quote:
Everybody is boring for your x64 requests. Try to share something useful posts here not only x64 aware filters/plugins requests.. Last edited by Nephilis; 23rd June 2011 at 09:54. |
|
23rd June 2011, 18:04 | #12 | Link | |
Acid fr0g
Join Date: May 2002
Location: Italy
Posts: 2,542
|
Quote:
Welcome, my new forum moderator.
__________________
@turment on Telegram |
|
23rd June 2011, 19:35 | #14 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
But, speaking frankly, it IS like that ...
Edit: Haha, Nephilis - this search I did a few moments ago, too. Edit#2: @tormento: Funnily, this filter here can be run under Avisynth-x64 practically without any problem. The builds of MVTools-x64 and ttempsmooth-x64 are out there. You have to ditch Blockbuster, but that's not essential for "the method" anyway. Just cancel it, or replace with AddGrain or Gradfun2db. And ba-DANG - another filter you can use with Avisynth-x64 until the next script crash.
__________________
- 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!) Last edited by Didée; 23rd June 2011 at 19:42. |
16th April 2013, 11:08 | #17 | Link |
Registered User
Join Date: Mar 2003
Location: UK
Posts: 360
|
Just changed your code very slightly to point directly to the extra filters needed so you don't have to hunt them down
####################################################################################################### # # ~HQDegrain v0.9.2 by Alek93j~ 29/06/2011 # # Required MVtools2.dll http://avisynth.org.ru/mvtools/mvtools-v2.5.11.3.zip # ttempsmooth.dll http://www.missouri.edu/~kes25c/TTempSmoothv094.zip # mt_masktools-25.dll http://manao4.free.fr/masktools-v2.0a48.zip # blockbuster.dll http://avisynth.org/warpenterprises/files/blockbuster_20_dll_20021229.zip # removegrain.dll http://home.arcor.de/kassandro/prerelease/RemoveGrain-1.0.rar # # ~Syntax~ ####################################################################################################### |
Thread Tools | Search this Thread |
Display Modes | |
|
|