View Full Version : GradFun2DBmod [v1.5 - Update 2009/12/30]
LaTo
23rd January 2009, 21:29
########################################################################################
### ###
### GradFun2DB MOD : function GradFun2DBmod() ###
### ###
### v1.5 by "LaTo INV." ###
### ###
### 30 December 2009 ###
### ###
########################################################################################
###
###
### /!\ Needed filters : Masktools (v2.0a36), Removegrain (v1.0PR),
### -------------------- GradFun2db (v1.0), AddGrainC(v1.4).
###
###
### USAGE: GradFun2DBmod( thr, thrC, mode,
### str, strC, temp, adapt, custom,
### mask, radius, range,
### show, screenW, screenH )
###
###
### +--------+
### | DITHER |
### +--------+
###
### thr [default: 1.2]
### ------------------
### GradFun2DB "thr" parameter
###
### thrC [default: thr]
### -------------------
### GradFun2DB "thrC" parameter
###
### mode [default: 2]
### -----------------
### Mode for the addition of 16 pixels around the image
### 0 = Off [same as GradFun2DB]
### 1 = AddBorders (speed:+ quality:-) [same as GradFunk]
### 2 = PointResize (speed:+ quality:+)
### 3 = Flip/Stack (speed:- quality:+) [same as GradFunkMirror]
###
###
### +-------+
### | GRAIN |
### +-------+
###
### str [default: 0.8]
### ------------------
### AddGrainC "var" parameter
###
### strC [default: 0.0]
### -------------------
### AddGrainC "uvar" parameter
###
### temp [default: 50]
### ------------------
### Strength for temporal stabilization
### -1 = off
### 0 = nervous grain
### ..
### 100 = calm grain
###
### adapt [default: 64]
### -------------------
### Threshold for luma-adaptative grain
### -1 = off
### 0 = source
### ..
### 255 = invert
###
### custom [default: "empty"]
### -------------------------
### Use your own grain generator instead of AddGrain
### (temp & adapt parameters are on, set -1 to turn off)
###
###
### +------+
### | MASK |
### +------+
###
### mask [default: true]
### --------------------
### Use adaptative deband mask
### (dither/grain is only applied to areas with banding's susceptibility)
###
### radius [default: 2]
### -------------------
### Radius for the mask (1 is the fastest, 2-3 are slower)
###
### range [default: 2]
### ------------------
### Range used in the mask (1-3 are good value)
###
###
### +-------+
### | DEBUG |
### +-------+
###
### show [default: false]
### ---------------------
### Show debug clip & informations
###
### screenW [default: 1280]
### -----------------------
### Screen horizontal resolution (for show clip)
###
### screenH [default: 1024]
### -----------------------
### Screen vertical resolution (for show clip)
###
########################################################################################
Update 2009.12.30 : GradFun2DBmod v1.5 (http://latoninf.free.fr/d9/GF/GradFun2DBmod.v1.5.avsi)
v1.5:
added MOD4 restriction
changed script to accept MOD8 clip
updated documentation
v1.4:
changed "temp" parameter (-1=off)
updated documentation
v1.3:
replaced chroma parameter by thrC & strC
v1.2:
changed int->float for str parameter
added custom parameter
v1.1:
added show parameter
added small speed improvements
added warning for bad settings
fixed small bug with chroma=false
v1.0:
first public release
http://latoninf.free.fr/d9/GF/show_mini.png (http://latoninf.free.fr/d9/GF/show.png)
LaTo
23rd January 2009, 21:30
A mix of Udeband / GradFunk with new features... :cool:
I will add screenshots later...
jase99
23rd January 2009, 23:02
Wow, that was timely. Just what I was looking for. Thank you.
Adub
23rd January 2009, 23:42
I long for the days when we will no longer need dithering and have high enough color bit depth to remove banding all together.
Oh, and LaTo, what's this? You posting a script with no "show" parameter! ;) Nah, it aint necessary but I got used to it. It's simple enough to implement my own source view.
LaTo
24th January 2009, 08:10
I long for the days when we will no longer need dithering and have high enough color bit depth to remove banding all together.
Yes, this is clearly one of the biggest problems with DVD/Bluray (and others YV12 source) :mad:
Oh, and LaTo, what's this? You posting a script with no "show" parameter! ;) Nah, it aint necessary but I got used to it. It's simple enough to implement my own source view.
:D
Maybe later, I haven't time these days...
LaTo
24th January 2009, 19:44
v1.1:
added show parameter
added small speed improvements
added warning for bad settings
fixed small bug with chroma=false
Omission is repaired :D
LaTo
25th January 2009, 20:35
Please re-download the v1.1 because I made a mistake in the show function :rolleyes:
Adub
26th January 2009, 08:44
v1.1:
added show parameter
Haha!! Okay, now it's perfect! I have some anime that I can/need to test this on. If only I can find the time.
McCauley
26th January 2009, 12:20
Hi LaTo,
great script, thanks!
Would it be feasible to implement the possibility to call an external Grain Generator (=Grainfactory3) instead of AddGrain?
Regards
McCauley
Sagekilla
26th January 2009, 17:25
Ctrl+F -> AddGrain -> Replace with your choice ;)
LaTo
26th January 2009, 20:55
Hi LaTo,
great script, thanks!
Would it be feasible to implement the possibility to call an external Grain Generator (=Grainfactory3) instead of AddGrain?
Regards
McCauley
Why not... I will add a switch between Addgrain & GrainFactory3 later.
thetoof
26th January 2009, 21:37
You could do it as string "mygraingen" and use eval in the script. This way, you wouldn't need to add all the possible parameters in gradfun2dbmod. (+ more flexibility if the user wants to use a combination of filters, etc etc) mygraingen="grainfactory3(blabla).something else()"
McCauley
26th January 2009, 22:25
You could do it as string "mygraingen" and use eval in the script. This way, you wouldn't need to add all the possible parameters in gradfun2dbmod. (+ more flexibility if the user wants to use a combination of filters, etc etc) mygraingen="grainfactory3(blabla).something else()"
That's exactly what i had in mind, but i didn't really understand how to implement it with eval().
Regards
McCauley
Sagekilla
26th January 2009, 22:47
One way you can do this is to make a helper function.
function EvalFunction(clip src, string "filter")
{
src
processed = Eval(filter)
return processed
}
It makes script writing easier too:
# Without the helper function you have to do this:
Avisource("..")
src = last
proc = src.SomeFiltering()
src
dither = Eval("Blur(1)")
# With the helper function you can do this:
Avisource("...")
src = last
proc = src.SomeFiltering()
dither = src.EvalFunction("Blur(1)")
Codex0nz
26th January 2009, 23:14
Wow took me a minute to see the difference without cheating by looking at the bottom, looks fantastic man.
So this filter mainly removes grainy sort of damage?
What program did you use to produce that shot for comparing, could save myself a lot of time if you're willing to care and share :D
Nightshiver
26th January 2009, 23:21
This filter is for debanding.....
Codex0nz
26th January 2009, 23:50
This filter is for debanding.....
In my defense its still tuesday morning here -_-
The banding is caused by grain though is it not? i'll shut up now...
Nightshiver
27th January 2009, 00:46
No, not always. Grain is sometimes put in movies to cover up banding. It is also caused by bad color gradients/color. In his example picture, there was practically no grain.
Sapo84
27th January 2009, 03:00
I think str parameter should be float (it is float in addgrain).
Otherwise it's really a good script, I tried it on some anime clips and it works very well, a lot better than a simple GradFun2DB.
The only problem is that anime shouldn't really have any grain so the default parameters need a little bit of tweaking :sly: (supersampling may help too).
LaTo
28th January 2009, 17:51
v1.2:
changed int->float for str parameter
added custom parameter
LaTo
28th January 2009, 18:19
PS: If you really want supersampling (I haven't seen any enhancement):
custom="spline36resize(resolution*2).addgrain(xx,0,0).spline36resize(resolution)"
:D
McCauley
28th January 2009, 18:35
Thanks for the custom clip!
Added to the wiki (http://avisynth.org/mediawiki/External_filters#Debanding).
Regards
McCauley
thetoof
28th January 2009, 20:00
Could you give the pros/cons of the different parameters in the guide... you only name them, which is not very useful for unexperienced users. (that aside, good job ^_^)
stpdrgstr
3rd February 2009, 02:19
I've been testing this, and is quite good, the only parts of the image dithered are the ones that really need it.
Though, I don't really see any difference from temp=100 or using temp=50, the grain looks the same "jumpy" with any of these.
OrionZodiac
11th February 2009, 01:25
I didn't want to start a new thread, so i posted my ply for help here.
This is the first 10 seconds of freedom OVA ep#2. The source has virtually no grain, however the color gradient is HORRIBLE. I have been trying for days trying to get rid of the banding in some way or another, but the end-result does not look very good. Somebody please take a look at the purple area in the background and tell me if you have a good solution for the banding here.
http://www.megaupload.com/?d=GM7IZQR2
Thank you
LaTo
11th February 2009, 16:30
v1.3:
replaced chroma parameter by thrC & strC
LaTo
11th February 2009, 16:38
I didn't want to start a new thread, so i posted my ply for help here.
This is the first 10 seconds of freedom OVA ep#2. The source has virtually no grain, however the color gradient is HORRIBLE. I have been trying for days trying to get rid of the banding in some way or another, but the end-result does not look very good. Somebody please take a look at the purple area in the background and tell me if you have a good solution for the banding here.
http://www.megaupload.com/?d=GM7IZQR2
Thank you
GradFun2DBmod(thr=1.2,thrC=1.8,str=0.0,strC=0.0)
edit: If the effect disappear when encoding, you should increase str & strC until the dither remains.
Video Dude
26th February 2009, 18:27
Can GradFun2DBmod be applied straight to interlace video?
Or should a SeparateFields or the Bob/filter/reinterlace method be used to apply GradFun2DBmod to interlaced video?
swaaye
20th April 2009, 05:25
Could someone please post AddGrainC 1.4 somewhere? The link from the avisynth plugin page to foxyshadis site is dead and I can't find the v1.4 plugin anywhere. Only managed to find 1.3....
Socio
20th April 2009, 13:47
LaTo I have a side question; what app are you using in that side by side comparison in the OP?
Thanks
LaTo
20th April 2009, 14:14
LaTo I have a side question; what app are you using in that side by side comparison in the OP?
Thanks
No app, just: GradFun2DBmod(show=true)
Socio
20th April 2009, 15:22
No app, just: GradFun2DBmod(show=true)
Ok got it :thanks: playing around with it now;
http://img523.imageshack.us/img523/5941/1gran.th.jpg (http://img523.imageshack.us/my.php?image=1gran.jpg)
hartford
21st April 2009, 02:59
Could someone please post AddGrainC 1.4 somewhere? The link from the avisynth plugin page to foxyshadis site is dead and I can't find the v1.4 plugin anywhere. Only managed to find 1.3....
I've uploaded to the forum the 1.4 plugin:
http://forum.doom9.org/showthread.php?t=51320
It may take time before it is approved.
Hopefully, Warpenterprises will replace the old with the new.
Where did I get this? I don't recall.
SPiKA
23rd April 2009, 19:18
Thanks LaTo, this script is amazing!
Nephilis
3rd May 2009, 16:50
Where should i use GradFun2DBmod () (to avoid color blocking in dark areas in a frame) in the filterchain? At the last of script or somewhere else? Before or after sharpen, denoise ?
Thanx in advance..
It's rather pointless to use it before denoising... xD
Sagekilla
3rd May 2009, 21:34
Generally I would use debanding after denoising, but not before sharpening. If you do it before sharpening, the sharpener may accidentally sharpen your dither.
i.e:
Denoise()
Deband()
or
Denoise()
Sharpen()
Deband()
Nephilis
4th May 2009, 12:41
I'll do it so
Denoise()
Sharpen()
Deband()
Thanx a lot Sagekilla..
it's me or it's horribly slow ? :D
Sagekilla
6th May 2009, 03:06
Well yes, It's slower than your standard Gradfun2db, but that's because it has multiple masktools operations and some temporal soften + add grain sprinkled in. Temporal soften is fairly slow, and the mt_lut's don't help any either ;)
Korben
3rd September 2009, 23:01
Nice feature. Why is it not possible to use YUY2? I got an error message:
---------------------------
VirtualDub Error
---------------------------
Avisynth open failure:
This is not an YV12 clip ! Please convert color space to YV12 before using GradFun2DBmod()
(GradFun2DBmod.v1.3.avsi, line 136)
(E:\Capture\Project_107\1tdecimate.avs, line 91)
---------------------------
OK
---------------------------
Adub
4th September 2009, 18:15
It has to due with it's supporting plugins. One(or more) of them do not support YUY2. Simple as that.
Benus_MinO
18th October 2009, 14:25
LaTo, how I can obtain results like this?:
http://img197.imageshack.us/img197/7634/imgxc.th.png (http://img197.imageshack.us/i/imgxc.png/)
Here is source:
http://pi.fastbighost.com/~benus/Banding.m2ts
LaTo
18th October 2009, 18:57
LaTo, how I can obtain results like this?:
http://img197.imageshack.us/img197/7634/imgxc.th.png (http://img197.imageshack.us/i/imgxc.png/)
Here is source:
http://pi.fastbighost.com/~benus/Banding.m2ts
Something like this should do the job: GradFun2DBmod(thr=1.6,thrC=1.2,str=0.8,strC=0.4)
Benus_MinO
18th October 2009, 19:27
Thank you.
VincAlastor
25th November 2009, 08:24
very good filter, thank you La To. but for daily using to slow! - is there a direct compute plan? ;)
LaTo
25th November 2009, 18:26
v1.4:
changed "temp" parameter (-1=off)
updated documentation
LaTo
25th November 2009, 18:28
very good filter, thank you La To. but for daily using to slow! - is there a direct compute plan? ;)
For faster settings try:
GradFun2DBmod(adapt=-1,temp=-1)
It should be a big speed up ;)
PS: For realtime processing (viewing) you can also add mask=false.
Dreadkillz
15th December 2009, 08:22
Hi, Lato.
Could you explain what "adapt" does? When I set adapt to high values, I see more noise on brighter areas than darker areas. Setting adapt to low values, I see more noise on darker areas than brighter areas.
ryrynz
15th December 2009, 10:58
Lato, loving your LSFmod, and am using it in conjunction with deband in ffdshow in most of my scripts. Would the settings you mentioned above be an adequate replacement for deband? Is there a setting that provides in your opinion better image quality with a similar performance impact? Awesome work man.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.