Log in

View Full Version : Stronger deblocking in dark/almost black areas


McCauley
1st February 2008, 12:11
Hello everyone,

i'm currently searching for a way to reduce blocking only in dark areas without smoothing the rest of my picture. The blocking isn't really a problem for the image quality, since the blocks are so dark, they aren't affecting the PQ much, but obviously they are messing up the compressibility.
A while ago i stumbled over this (http://forum.doom9.org/showpost.php?p=1033464&postcount=2) thread, i remembered it and modified the function to fit my needs.

Unfortunatelly it does more or less nothing, no matter how high the deblocking values are set.

src = AVCSource("bla.dga", deblock=false).assumefps(24000,1001).trim(107,0)

dx = 1280
dy = 692
sf= 1.3

th_low = 18
th_high = 28

a = src.deblock_qed(quant1=20,quant2=36,aOff1=2,bOff1=4,aOff2=4,bOff2=8).Crop(2, 22, -2, -30)
b = src.deblock_qed(quant1=80,quant2=96,aOff1=2,bOff1=4,aOff2=4,bOff2=8).Crop(2, 22, -2, -30) #i know these are very high values, just for testing purposes

dmask = a.levels(th_low,1.0,th_high,255,0,false)

a.mt_merge(b,dmask,U=3,V=3, luma=true)

SootheX(LSFs36(ss_x=sf, ss_y=sf, smode=3, strength=110, overshoot=1, dest_x = dx, dest_y = dy ),Spline36resize( dx, dy ), 30)

tweak(bright=50, cont=1.8) #only for making blocking more visible


Has anyone some suggestions how to improve my script, respectively make it working?

Regards and thanks in advance
McCauley

Didée
1st February 2008, 13:08
First of all, set deblock=true in AVCSource. If the source used inloop deblocking, and you forcely disable inloop deblocking during decoding, then the output will have blocking that shouldn't be there at all.

Also, try a plain "b = src.deblock(quant=??)..." for the dark parts. Maybe even combined with some gradfun2db, since the "blocking" might be not true blocking in technical terms, but rather the usual coding inaccuracies that are typical for dark areas. In that case a deblocking filter alone will have only little success, obviously.

McCauley
1st February 2008, 14:23
Thanks for your fast reply, i'll try out your suggestions when i'm back at home.
gradfun2db didn't do what i hoped it would do, but maybe it will do what i want after i aplied your suggested settings.

Regards
McCauley

McCauley
5th February 2008, 12:11
If anyone is interested in my results:
The script worked very nice with the the inloop deblocking turned on and the stronger deblocking Didèe suggested.
Those are my settings:
src = AVCSource("bla.dga").assumefps(24000,1001).trim(107,0)

dx = 1280
dy = 692
sf= 1.3

th_low = 18
th_high = 28

a = src.deblock_qed(quant1=20,quant2=36,aOff1=2,bOff1=4,aOff2=4,bOff2=8).Crop(2, 22, -2, -30)
b = src.deblock(quant=40).Crop(2, 22, -2, -30).gradfun2db(1.5).tweak(bright=-1)

dmask = a.levels(th_low,1.0,th_high,255,0,false)

a.mt_merge(b,dmask,U=3,V=3, luma=true)

SootheX(LSFs36(ss_x=sf, ss_y=sf, smode=3, strength=110, overshoot=1, dest_x = dx, dest_y = dy ),Spline36resize( dx, dy ), 30)

#tweak(bright=50, cont=1.8)

Note that i reduced the brightness of the masked clip to counter the overall luma increase caused by gradfun2db's debanding, so the intended black is again black

Regards
McCauley

raziel666
7th February 2008, 11:39
Seems like an interesting script. I wanted to try it but couldn't find anything about SootheX or LSFs36. Could you post a link or two? Thanks alot.

EDIT: I think I found that SootheX is the original Soothe function Didée posted some time ago, somewhere here (http://forum.doom9.org/showthread.php?p=708217#post708217).

talen9
7th February 2008, 12:23
I *suppose* that LSFs36 is simply the standard LimitedSharpenFaster in which every instance of LanczosResize is replaced by a Spline36Resize ... just guessing, anyway :p

raziel666
10th February 2008, 09:57
There is no LanczosResize in LimitedSharpenFaster. There are BicubicResize() and Spline36Resize() by default. So any other ideas?

talen9
11th February 2008, 00:59
Hmmm .... in the version of LSF that I'm using, there's definitely the Lanczos ... maybe I've an outdated version, and you're *already* using LSFs36 without knowing? :p

Adub
11th February 2008, 06:33
The LSF version on the Avisynth Wiki has the spline resizers, so perhaps you are working with an older version.

talen9
11th February 2008, 19:21
Hmmm ok time to upgrade then :p

Meanwhile, raziel666 is still wondering what LSFs36 is ....

foxyshadis
12th February 2008, 07:48
This is why you always either post your customized functions or edit your sample scripts to use the "standard" versions when you're going to post something.