View Full Version : Need Suggestions for VERY GRAINY source
Boulder
28th December 2007, 10:54
SAD1 = default( SAD1, 300 ) # Threshold for degraining, decrease for more effectIsn't this the other way around, a lower threshold means less effect?
Terranigma
28th December 2007, 15:46
SAD1 = default( SAD1, 300 ) # Threshold for degraining, decrease for more effectIsn't this the other way around, a lower threshold means less effect?
Depends. For thsad strength in mvdegrain, yes, but for other means such as mvmask, a lower value will result in more areas being affected. For the ml value, I usually have it to whatever the thsad strength is divided by 8.
Boulder
28th December 2007, 16:17
Depends. For thsad strength in mvdegrain, yes, but for other means such as mvmask, a lower value will result in more areas being affected. For the ml value, I usually have it to whatever the thsad strength is divided by 8.Yes, I meant threshold in MVDegrain as is it used in the function :)
Sagekilla
28th December 2007, 19:44
I fixed a few things, mostly cosmetics and (hopefully) fixed that line break screwup. Also fixed a potential error from having too low of a sigma, since I had sigma2,3,4 based off sigma 1 on a subtraction basis. It now works as a (rounded) fraction of sigma. Still, you shouldn't need to adjust it or any of the params, except maybe enabling HQ mode, since the script works great at defaults.
Updated script is at post #116 (http://forum.doom9.org/showpost.php?p=1078534&postcount=116)
CruNcher
14th January 2008, 19:05
Didee how did you avoid Grain in Motion in your easy.mkv?, all my tries endup in grain when characters move :(
Didée
14th January 2008, 21:16
how did you avoid Grain in Motion in your easy.mkv? By mumbling some secret incantations while the posted script (http://forum.doom9.org/showthread.php?p=1076276#post1076276) was rendering. :)
Zep
14th January 2008, 21:50
Didee how did you avoid Grain in Motion in your easy.mkv?, all my tries endup in grain when characters move :(
note the huge problem though that Didee posted about later.
it is very nasty and I had to end up not using motion vectors at all cause they just screw up too much and are also so darn slow to calc.
My current testing I have dumped all MV calls and I am doing just masking like I was doing at the start of thread. It is sorta a hybrid now from how I started out and Didee's script and it works better than either way. No MVAnalyse artifacts when it can not figured out what to do which is often in this very high motion movie.
BTW - Didee I am doing the full 1080p now and not 720p anymore and the detail is just so sweet :)
Sagekilla
14th January 2008, 22:50
By mumbling some secret incantations while the posted script (http://forum.doom9.org/showthread.php?p=1076276#post1076276) was rendering. :)
Or the associated function (http://forum.doom9.org/showpost.php?p=1078534&postcount=116) made from magical bits, which can make things easier :)
CruNcher
14th January 2008, 23:37
oops i see i removed that part when trying to make it processing faster (minblur) thought it was belonging to the contrast sharpener as a whole ;)
Great Dragon
28th January 2008, 15:51
How can i use MT with this function?
setmtmode(any) - dont work. CPU load is 25% only, and speed dont increase.
MT("temporaldegrain()",4,4) - picture get broken.
Sagekilla
28th January 2008, 19:02
I don't use MT() actually. I use the MTified version of Avisynth, and use the following:
SetMTMode(2)
TemporalDegrain()
Gives me usually 80% speed boost. I have to debug and see how the function plays with MT(), because I've never used it thus far. On a side note, have you tried using other MT modes, like 2, 3, or 5?
I have to update the function anyway, it's quite borked at the moment in several aspects because of my muddling around.
Latest vesrion is in #116 (http://forum.doom9.org/showpost.php?p=1078534&postcount=116)
Dreassica
28th January 2008, 19:42
Odd, MT(2) doesn't give me any speedboost at all with this script, on a q6600 its 1.6fps for both standard and MT().
Sagekilla
28th January 2008, 19:51
Odd indeed, because I've seen my virtualdubmod scripts run faster with it on. This was when I was testing a very old version of this script though.. Things may have changed in between, so I'll have to do testing again to see if this still holds true. Also, I did some testing and found MVTools functions don't like to play nice with MT()
Try running the following as a function. It won't work at all. So no multithreading for the MVDegrain, unfortunately.
Avisource("test.avi")
MT("Degrain(),2,2")
function Degrain ( clip input )
{
o = input
b2vec = o.MVAnalyse(isb=true, delta=2, pel=2, idx=1)
b1vec = o.MVAnalyse(isb=true, delta=1, pel=2, idx=1)
f1vec = o.MVAnalyse(isb=false, delta=1, pel=2, idx=1)
f2vec = o.MVAnalyse(isb=false, delta=2, pel=2, idx=1)
NR1 = o.MVDegrain2(b1vec,f1vec,b2vec,f2vec,thSAD=300,idx=2)
return(NR1)
}
Sagekilla
28th January 2008, 20:02
Alright, I've done a quick test on 50 frames and without SetMTMode(2), it took 31 seconds to run the script. With SetMTMode, it took 23 seconds less. Roughly 35% faster with multithreading.
Conspiracy theories anyone?
Dreassica
28th January 2008, 20:10
That little script doesnt load.
Didée
28th January 2008, 20:21
Sagekilla, the script in post#161 can't work: "2ssD" in the contra-sharp section is a plain impossibility, it should read "ssD". ;)
Also, SeeSaw is in there now ... what a pity.
edit: script in post#163 is missing a ")" parenthesis at the end of line 2.
Adub
28th January 2008, 20:39
What versions of Masktools and MVtools do you have?
Sagekilla
28th January 2008, 20:53
Sagekilla, the script in post#161 can't work: "2ssD" in the contra-sharp section is a plain impossibility, it should read "ssD". ;)
Also, SeeSaw is in there now ... what a pity.
edit: script in post#163 is missing a ")" parenthesis at the end of line 2.
Fixed everything, thanks for that Didee. Very bad with syntax today it seems.
Dreassica
28th January 2008, 21:14
Still getting a syntax error from that line.
Didée
28th January 2008, 21:20
I've no clue about MT stuff, I'm on single core only ... however
MT("Degrain()",2,2)
would seem logical.
Sagekilla
28th January 2008, 21:21
Yeah, that whole line got narfed up. It was just a script to demonstrate that MV Tools and MT don't play nicely, except I keep screwing up the script somehow.
Dreassica
28th January 2008, 21:22
Yep, moved the " and now it loads fine.
Video is screwed up though.
Using setmtmode(2,4) it works fine. Oddly here I do get a significant boost in speed. from 1.15min on a 1000 frame sample without, to 24 seconds with setmtmode. But I get zero speedincrease with temporaldegrain script.
Boulder
28th January 2008, 21:26
MT and MVTools don't work together. You need to use SetMTMode if you want multithreading.
Sagekilla
28th January 2008, 21:30
Yep, moved the " and now it loads fine.
Video is screwed up though.
Exactly my point: The reason why MT("Temporal_Degrain",2,2) doesn't work (graphical errors) is because MT and MVTools shouldn't mix. One particualr thing is idx needs to be unique for each thread, according to this (http://forum.doom9.org/showthread.php?t=94996&page=33) (See first post)
Dreassica
28th January 2008, 21:33
Well then why does setmtmode work fine then? Or am I missing something here.
Boulder
28th January 2008, 21:38
MT splits the frame in multiple halves, SetMTMode processes multiple whole frames simultaneously.
Dreassica
28th January 2008, 21:46
Guess I did miss something basic then :)
Still odd that I don't get any benefit from using it on temporalgrain only.
Sagekilla
28th January 2008, 21:50
Guess I did miss something basic then :)
Still odd that I don't get any benefit from using it on temporalgrain only.
Indeed, you said you're running a Q6600? I'm running an Opteron 170 (dual core) and SetMTMode(2) provides me a 35% speed boost. Try this:
SetMTMode(2)
Avisource("file.avi")
Trim(2000,2049)
TemporalDegrain()
Then run it through VirtualDubMod, tell it to save as Lagarith on your hard drive and check the time it takes. Run another version of the script, except without SetMTMode(2) and check the time. There SHOULD be a speedup, I see no reason for it not to.
Dreassica
28th January 2008, 22:02
Odd just caling it without arguments i get roughly 4 to 5 times the fps with setmtmode, maybe callign slowest arguments in temporaldegrain kills any advantage I'dget with setmtmode, as I only get .1 increase in fps.
Used TemporalDegrain(degrain=3,sad1=100,sad2=100,pel=4,ov=4)
Sagekilla
28th January 2008, 22:09
Odd just caling it without arguments i get roughly 4 to 5 times the fps with setmtmode, maybe callign slowest arguments in temporaldegrain kills any advantage I'dget with setmtmode, as I only get .1 increase in fps.
Used TemporalDegrain(degrain=3,sad1=100,sad2=100,pel=4,ov=4)
That's because TemporalDegrain defaults to degrain=2, sad1=300, sad2=300, pel=2, ov=4. You used much slower settings (namely pel=4 and degrain=3) so that's why it was so much faster. Also, try giving HQ=2 a spin. TD defaults to HQ=1, but 2 enables HQdn3D prepass for the motion vector search. It usually gives a small boost in compression ratios.
Dreassica
28th January 2008, 22:15
But is it THAT slower taht it completely nullifies multithreading advantage??
Sagekilla
28th January 2008, 22:19
But is it THAT slower taht it completely nullifies multithreading advantage??
I'll have to take a look and see.. By using MVDegrain3, you're using two extra frames to denoise (slower there), and you have to analyze another two frames (even slower). Plus, you're using twice the subpixel resolution so that slows things down even further. I usually use TemporalDegrain(HQ=2,degrain=2) and it gets the job done nicely, since pel=4 usually gives very minimal benefit. You'd get more out of going to Degrain=3 than going from pel=2 to pel=4 in any of the degrains, I blelieve.
It COULD be possible by using MVDegrain3, the function becomes so CPU bound on the MVTools functions that there's little benefit gained from using threading in the other filters. You can try using threads=2 to enable FFT3DFilter's built in multithreading, see if that helps any.
Dreassica
28th January 2008, 22:26
Oddly, increasing threads to 6 significantly boosts speeds up from 1.6fps to 3.2fps, tried 8 but then vdub shuts down after 10 secs.
Sagekilla
28th January 2008, 22:37
Odd indeed.. Perhaps it has something to do with how SetMTMode works -- since it works on a frame by frame basis, and now you're processing 6 full frames.
Sagekilla
12th February 2008, 06:18
Updated the script. It now does one last pass to remove any stray bits of dancing grain/noise. Was playing around with 300 and found that a (mostly) temporal HQDn3D could remove the tiny bits remaining. Enjoy. (http://forum.doom9.org/showpost.php?p=1078534&postcount=116)
Zep
12th February 2008, 22:57
Oddly, increasing threads to 6 significantly boosts speeds up from 1.6fps to 3.2fps, tried 8 but then vdub shuts down after 10 secs.
Most of the time it means you ran out of memory and Virtual memory doesn't help. You could increase VM and not crash but it will slow you way down.
Nikos
12th February 2008, 23:47
From post #116
SAD1 = default( SAD1, 300 ) # Threshold for degraining
From post #148
SAD1 = default( SAD1, 300 ) # Threshold for degraining, decrease for more effect
Small values mean more denoising or the opposite?
Any other parameter that affect the strenght of the denoising?
From old Fizick post:
There is no "filtering strength" parameter in MVDegrain.
It uses "simple" (i.e. very complex) temporal averaging.
The more frames, the more averaging.
But you can get more strong filtering with "overlap" option (up to half of block size).
I am a little confuse....
Thanks
Sagekilla
13th February 2008, 01:17
Ignore what I said in later posts. The script in #116 is the official one, all comments in other posts like #148 should be completely ignored. In #148, the reason why I commented SAD1 as having a greater effect was because when I tested it, lower values tended to have a stronger effect while higher ones had weaker effects. This was based entirely on my sample of 300 though, and should be taken with a grain (Ha! I cringed making that pun) of salt.
To answer your question though, if you read the MVtools documentation it points out what thSAD really is. thSAD determines the weighting applied to a pixel when MVDegrain processes a pixel. So, while it's not really a "strength" parameter, it can determine what gets processed and what doesn't.
Manao or Fizick, please correct me here if I'm wrong :) This is just based on my interpretation of the documentation.
Note: I'll be going back to remove all instances of my old function so there is no confusion as to which one is the latest instance.
Nikos
13th February 2008, 01:50
Thanks Sagekilla for the answer, but my wonder remain.
If i want more denoise or less denoise than default, which parameters i must change?
Sagekilla
13th February 2008, 01:58
If you're using my Temporal Degrain, a very rudimentary way of adjusting the strength is by using MVDegrain with 1, 2, or 3 frames backwards/forwards. Less frames means less (and faster) filtering, more frames means more (and slower) filtering. That's the most direct way of changing filtering strength, but not the best. I advise you to play around with the thSAD2 and thSAD1 (more so the thSAD2) parameters to see how much iltering you get out of it. In the mean time, I'll play around with my own function (which I still don't know the breadth of it's functionality) to give you a better answer.
If you're talking about the actual MVDegrain on it's own, that would be (as above) the thSAD parameter. To quote the MVTools documentation: "Low values can result in staggered denoising, large values can rezult in ghosting and artefactes." In other words, low thSAD is less denoise, high thSAD is more denoise.
Nikos
13th February 2008, 02:14
Thanks again for the answer. I had read the mvtools documentation but i don't understand what mean exactly the word staggered :)
My native language it's not english.
I am happy with your function, the results are satisfactory!!!
I experiment with HD movies from moderate quality Blu-ray with a lot of nasty grain.
Sagekilla
13th February 2008, 02:34
Staggered means that the denoising will be.. "jumpy" that is, it will not be constant denoising. Some frames will be denoised, while others will not. The following line is an example of a "staggered" result, where x means it was denoised properly and y means it wasn't touched at all: xxxyxyyxyxy. What we want is a sequence like xxxxxxx, not xxyxyyxy.
Also, big credit goes to Didee for giving me a starting point.
Nikos
13th February 2008, 02:52
Also, big credit goes to Didee for giving me a starting point.
Sure, i am a Didee fan to.
Adub
13th February 2008, 06:55
@Sagekilla
I will be adding your script to the Avisynth wiki soon. Just letting you know. Feel free to edit the page when I finish. I will post a link to it when I am finished (probably tomorrow).
Jawed
13th February 2008, 16:27
Instead of "staggered" I'd use the word "patchy". e.g. in the sky you might see areas where the denoising is strong and other areas where there is more noise.
At the other extreme, when the denoising is too strong this causes areas of the picture to move around for no apparent reason.
Also you will find that moving parts of the picture will have a ghost, following them around. So, when someone moves from left to right you might see a faint version of that person following just behind them.
It's worth experimenting, but you need to use a variety of clips to see these problems. One clip might show patchy denoising while another clip is better to see ghosting.
Jawed
Nikos
13th February 2008, 17:34
Thanks Jawed for further explanation for "staggered".
Sagekilla in your TemporalDegrain function why you put the HQDn3D(2,1,6,1) after Contra-sharpening and not before?
Also any idea for other "spat" filter.
Sagekilla
13th February 2008, 19:08
To be perfectly honest, I still don't even know what half of the function does (Most of it was made by Didee, who is a far better scripter than I am) Person you should be asking what could be used for spat should be Didee -- But I'll take a look at this and experiment to change things around.
Also, the idea behind putting HQDn3D there was simply to kill off any dancing grain or noise that was left since it's working in almost purely temporal fashion. I put it there after I found that it did this fairly well, but I haven't gotten around to testing where it should be. I'll take a look at it later on today in regards to where the best place to apply it would be (Before or after the sharpening, that is)
@Jawed: Thanks for the correct explanation :)
Edit: I placed HQDn3D before the contra sharpening now (Thanks, Nikos) and lowered the strength since in the context of TD, it was too strong. (The first time I tried this, using a rather simple filter chain it needed the higher settings, but here not as much) Updated copy in post #116 now.
Adub
13th February 2008, 20:06
Added TemporalDegrain to the Avisynth Wiki.
Link:
http://avisynth.org/mediawiki/Temporal_Degrain
Sagekilla
13th February 2008, 20:31
Thanks Merlin7777. Is there any way for me to link the most recent copy of the script to the page? I just uploaded v1.17 that had a few important changes, but I can't figure out how to link the download Temporal Degrain to it.
Nikos
13th February 2008, 21:18
Sagekilla i think that you must restrict the overlap up to blksize/2.
From Fizick post:
There is no "filtering strength" parameter in MVDegrain.
It uses "simple" (i.e. very complex) temporal averaging.
The more frames, the more averaging.
But you can get more strong filtering with "overlap" option (up to half of block size).
For other functions, overlap may be simply lesser block size.
For mvdegrain: ... like FFT3DFilter, overlap value up to blksize/2
Any overlap is summation. Any summation is averaging. i.e. partial denoising.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.