View Full Version : Uband - debanding flat areas only
anton_foy
16th August 2022, 23:01
Here is a little function I put together that I use all the time.
# Uband - debanding script based on neo_f3kdb to affect only "flat / non detailed" areas
# Requirements: neo_f3kdb, fft3dfilter, ex_tools, masktools2, sysinfo
function Uband(clip c, float "loC", int "grainY", int "grainC", bool "mt"){
loC = default( loC, 3.0 ) # smoothing strength of chroma in flat areas
# Neo_f3kdb parameters:
grainY = default( grainY, 23 )
grainC = default( grainC, 3 )
mt = default( mt, false )
mult= BitLShift(1,c.BitsPerComponent - 8)
nc = si_physicalcores()
O = c.bicubicresize(c.width/3,c.height/3).ex_edge(scale=3,"qprewitt").ex_expand().ex_invert().levels(0,0.1,212*mult,0,255*mult).bicubicresize(c.width(),c.height())
N = c.fft3dfilter(sigma=0,sigma2=0,sigma3=0,sigma4=loC,bt=1,plane=3,ncpu=nc).neo_f3kdb(grainY=grainY,grainC=grainC,mt=mt)
M = mt_merge(c,n,o,luma=true,Y=3,U=3,V=3)
S = c.bicubicresize(c.width/4,c.height/4).greyscale().levels(36*mult,0.16,70*mult,0,100*mult).ex_invert().bicubicresize(c.width(),c.height())
mt_merge(c,m,s,luma=true,Y=3,U=3,V=3)
return last}
Maybe useful for someone.
guest
22nd September 2022, 03:53
Here is a little function I put together that I use all the time.
# Uband - debanding script based on neo_f3kdb to affect only "flat / non detailed" areas
# Requirements: neo_f3kdb, fft3dfilter, ex_tools, masktools2, sysinfo
function Uband(clip c, float "loC", int "grainY", int "grainC", bool "mt"){
loC = default( loC, 3.0 ) # smoothing strength of chroma in flat areas
# Neo_f3kdb parameters:
grainY = default( grainY, 23 )
grainC = default( grainC, 3 )
mt = default( mt, false )
nc = si_physicalcores()
O = c.bicubicresize(c.width/3,c.height/3).ex_edge(scale=3,"qprewitt").ex_expand().ex_invert().levels(0,0.1,212*256,0,255*256).bicubicresize(c.width(),c.height())
N = c.fft3dfilter(sigma=0,sigma2=0,sigma3=0,sigma4=loC,bt=1,plane=3,ncpu=nc).neo_f3kdb(grainY=grainY,grainC=grainC,mt=mt)
M = mt_merge(c,n,o,luma=true,Y=3,U=3,V=3)
S = c.bicubicresize(c.width/4,c.height/4).greyscale().levels(36*256,0.16,70*256,0,100*256).ex_invert().bicubicresize(c.width(),c.height())
mt_merge(c,m,s,luma=true,Y=3,U=3,V=3)
return last}
Maybe useful for someone.
Hi anton,
I got this to work for me, but it seems to be fairly particular to the type of video I want to "Uband".
There is a problem with line 11, on some & line 14 on others.
Not sure why.
kedautinh12
22nd September 2022, 04:55
If you use ripbox which don't alarm what error exactly. Waste time for you and me to fix it
guest
22nd September 2022, 06:52
If you use ripbox which don't alarm what error exactly. Waste time for you and me to fix it
Now come on ked, it's RipBot !!!! ;)
Well, RipBot uses AVSMeter to check scripts, so unless there is another way to use AVSMeter so it does show what error, then that's all I can do, as I don't use any other app's !!!
I occasionally use Staxrip & Handbrake.
anton_foy
22nd September 2022, 12:47
Hi anton,
I got this to work for me, but it seems to be fairly particular to the type of video I want to "Uband".
There is a problem with line 11, on some & line 14 on others.
Not sure why.
Oh its hard for me to know which kind of error. 11 you say, that is"mt" and default is false so it is strange it shouldn't be a problem. Did you have all the required dlls?
guest
22nd September 2022, 14:28
Oh its hard for me to know which kind of error. 11 you say, that is"mt" and default is false so it is strange it shouldn't be a problem. Did you have all the required dlls?
Hi anton,
It just weird how it works on some video's but not on others, and I don't really know why.
Is there a particular "type" (colour space, etc) that it requires ??
But if you go here (where I answered another users question), you'll see my script (the bottom one) :-
https://forum.doom9.org/showthread.php?p=1975088#post1975088
StainlessS
22nd September 2022, 14:56
Is there a particular "type" (colour space, etc) that it requires ??
O = c.bicubicresize(c.width/3,c.height/3).ex_edge(scale=3,"qprewitt").ex_expand().ex_invert().levels(0,0.1,212*256,0,255*256).bicubicresize(c.width(),c.height())
N = c.fft3dfilter(sigma=0,sigma2=0,sigma3=0,sigma4=loC,bt=1,plane=3,ncpu=nc).neo_f3kdb(grainY=grainY,grainC=grainC,mt=mt)
M = mt_merge(c,n,o,luma=true,Y=3,U=3,V=3)
S = c.bicubicresize(c.width/4,c.height/4).greyscale().levels(36*256,0.16,70*256,0,100*256).ex_invert().bicubicresize(c.width(),c.height())
I have not really looked too hard at it, but all of the "*256" stuff makes it seem 16 bit specific to me.
8 bit *1, # * [ 2 ^ (8-8) ] ::: * BitLShift( 1 , 8-8)
10 bit *4, # * [ 2 ^ (10-8) ] ::: * BitLShift( 1 , 10-8)
12 bit *16, # * [ 2 ^ (12-8) ] ::: * BitLShift( 1 , 12-8)
14 bit *64, # * [ 2 ^ (14-8) ] ::: * BitLShift( 1 , 14-8)
16 bit *256. # * [ 2 ^ (16-8) ] ::: * BitLShift( 1 , 16-8)
BPC = BitsPerComponent(Src)
MULT = BitLShift( 1 , BPC - 8 ) # Multiplier
anton_foy
22nd September 2022, 16:33
O = c.bicubicresize(c.width/3,c.height/3).ex_edge(scale=3,"qprewitt").ex_expand().ex_invert().levels(0,0.1,212*256,0,255*256).bicubicresize(c.width(),c.height())
N = c.fft3dfilter(sigma=0,sigma2=0,sigma3=0,sigma4=loC,bt=1,plane=3,ncpu=nc).neo_f3kdb(grainY=grainY,grainC=grainC,mt=mt)
M = mt_merge(c,n,o,luma=true,Y=3,U=3,V=3)
S = c.bicubicresize(c.width/4,c.height/4).greyscale().levels(36*256,0.16,70*256,0,100*256).ex_invert().bicubicresize(c.width(),c.height())
I have not really looked too hard at it, but all of the "*256" stuff makes it seem 16 bit specific to me.
8 bit *1, # * [ 2 ^ (8-8) ] ::: * BitLShift( 1 , 8-8)
10 bit *4, # * [ 2 ^ (10-8) ] ::: * BitLShift( 1 , 10-8)
12 bit *16, # * [ 2 ^ (12-8) ] ::: * BitLShift( 1 , 12-8)
14 bit *64, # * [ 2 ^ (14-8) ] ::: * BitLShift( 1 , 14-8)
16 bit *256. # * [ 2 ^ (16-8) ] ::: * BitLShift( 1 , 16-8)
BPC = BitsPerComponent(Src)
MULT = BitLShift( 1 , BPC - 8 ) # Multiplier
Aaah yes I forgot this...
guest
23rd September 2022, 04:15
Aaah yes I forgot this...
Hi again, anton,
So is this the reason why it's "fussy" ??
How can this be fixed ??
Cheers
anton_foy
23rd September 2022, 07:23
Hi again, anton,
So is this the reason why it's "fussy" ??
How can this be fixed ??
Cheers
If you filter in 8bit then remove '*256' in the levels -lines in uband or '*1'. See StainlessS's post above for the different bitdepths.
What bitdepth do you filter in?
I will update this function soon to not be bitdepth specific.
guest
23rd September 2022, 07:30
If you filter in 8bit then remove '*256' in the levels -lines in uband or '*1'. See StainlessS's post above for the different bitdepths.
What bitdepth do you filter in?
I will update this function soon to not be bitdepth specific.
Hi, I generally don't check the bit of the video I want to encode, but x264 is generally 8bit, but I mostly encoded to 10bit & x265.
I will check what "bit's" the video's are, that Uband doesn't like.
But your updated next build should be good to go :)
:thanks:
StainlessS
23rd September 2022, 09:38
Just change to something like this, Untested.
# Uband - debanding script based on neo_f3kdb to affect only "flat / non detailed" areas
# Requirements: neo_f3kdb, fft3dfilter, ex_tools, masktools2, sysinfo
Function Uband(clip c, float "loC", int "grainY", int "grainC", bool "mt") {
loC = default( loC, 3.0 ) # smoothing strength of chroma in flat areas
# Neo_f3kdb parameters:
grainY = default( grainY, 23 )
grainC = default( grainC, 3 )
mt = default( mt, false )
mult= BitLShift(1,c.BitsPerComponent - 8)
nc = si_physicalcores()
O = c.bicubicresize(c.width/3,c.height/3).ex_edge(scale=3,"qprewitt").ex_expand().ex_invert().levels(0,0.1,212*mult,0,255*mult).bicubicresize(c.width(),c.height())
N = c.fft3dfilter(sigma=0,sigma2=0,sigma3=0,sigma4=loC,bt=1,plane=3,ncpu=nc).neo_f3kdb(grainY=grainY,grainC=grainC,mt=mt)
M = mt_merge(c,n,o,luma=true,Y=3,U=3,V=3)
S = c.bicubicresize(c.width/4,c.height/4).greyscale().levels(36*mult,0.16,70*mult,0,100*mult).ex_invert().bicubicresize(c.width(),c.height())
mt_merge(c,m,s,luma=true,Y=3,U=3,V=3)
return last
}
anton_foy
23rd September 2022, 10:21
Very nice StainlessS many thanks I will test it later today!
guest
23rd September 2022, 13:44
Very nice StainlessS many thanks I will test it later today!
Well, that's worked out pretty nice...
First of all for anton to put this little script together...
Me, for testing it, and finding it "fussy" with some types of video, and then commenting on it.
And for StainlessS, for chiming in, and "lending" his knowledge to figure out what was probably causing that issue :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.