Log in

View Full Version : Realtime SD Sharpening


Pages : [1] 2

Stormborec
11th December 2014, 19:11
Which sharpener (or type of sharpening) is suitable for DVD/SD realtime sharpening?
Something faster than LSF ... but more complex than sharpen() ...

btw. Which one is the in VLC (or what type) ...

foxyshadis
12th December 2014, 02:12
This is very dependent on your hardware. I could run LSF in realtime back in 2006 on a Core Duo laptop, before Core 2 appeared, but I had to adjust its settings. Now you have the possibility of doing it through shaders if you have reasonably competent graphics, much faster than AviSynth filters can.

Sticking with Avisynth, FineSharp (http://avisynth.nl/index.php/FineSharp) is fast and effective, even if it was designed for HD. It might be a bit too powerful for SD, but it's worth a shot. (A shader version of that exists, too.)

So what CPU, Graphics, and how much memory do you have?

TheSkiller
12th December 2014, 11:59
I use FineSharp all the time with SD. I lower some of the parameters compared to the defaults which are aimed at sharpening 1080p resized from a 720p source.

This is what I like to use for SD (meaning I apply this to 704x576 content):

FineSharp(sstr=1.5, lstr=2.5, xstr=0)

Stormborec
12th December 2014, 19:18
I have Celeron 2.60, integrated gpu, 512 MB RAM ... I can fluently play max. 720p. It isn't much, but for SD video it is OK. For some reasons (wrong calibrated TV) it needs still something for colorshift and enhance of saturation - coloryuv(off_u=5,cont_u=...,cont_v=...). Coloryuv doesn't consume much, therefore is there still some place for a sharpening ... that's the whole story

Finesharp - I look, that it requires same plugins like LSFmod - Masktools, Removegrain, Repair. So it would be similar like LSFmod ?
I thing, that LSFmod leaves the others lightweight sharpening plugins like Msharpen, Xsharpen far behind ...
But LSFmod is too slow for me.
I don't know, if somewhere is a comparison of different plugins/sripts - for real content. I found only something for cartoons.

How would you sharpened this:

http://s28.postimg.org/3l0mjh04p/1110.jpg (http://postimg.org/image/3l0mjh04p/)

feisty2
12th December 2014, 19:45
I don't think you can advanced sharpen videos on that computer at realtime
Maybe "unsharpen mask" is ur only choice left

Bloax
12th December 2014, 20:04
FineSharp might use the same plugins as LSF, but it's much simpler.

Stormborec
12th December 2014, 20:43
http://en.wikipedia.org/wiki/Unsharp_masking
Maybe that's the type of sharpening, that is used in VLC.


What about: http://avisynth.nl/index.php/UnFilter

Stormborec
12th December 2014, 23:00
I've done some tests:

http://www.imghosting.cz/images/9620.png (http://www.imghosting.cz/view-9620.png)

LSFmod without the supersampling has equal speed like FineSharp
UnsharpHQ - more than twice faster

And the winner is ...

FineSharp does a "clean work" - no warping, no pixel shift - but the output is quite noisy (maybe change of settings would help)

LSFmod in this setting is not much better than the very fast UnsharpHQ filter ...

The conclusion is - if settings of Finesharp coud be changed to lower the noise - then could be (beware - Badword) the best

Stormborec
13th December 2014, 01:41
Here is comparison with changed parameters:

http://www.imghosting.cz/images/7830.png (http://www.imghosting.cz/view-7830.png)


LSFmod "full firing"

Finesharp without XSharpen-style final sharpening (xstr) and without sharpening "flat areas" (ldmp)

Stormborec
16th December 2014, 19:08
So finally I decided for something else. The best quality in realtime for me seems to be:
LSFmod(defaults="old",strength=40,ss_x=1,ss_y=1), which is actually the old LSF.
Anything which uses supersampling is too slow for realtime playing.
This settings don't takes benefits from supersampling but UnshrapHQ not also.
Btw. the sharpen mode in presset "old" is unsharp masking from warpsharp.
LSF in this setting is a bit faster than UnsharpHQ and also less halloing ...

Stormborec
18th December 2014, 20:39
My final script that looks like this:


directshowsource("") #640×368

crop(0,2,-0,-4)
spline36resize(640,358)


LSFmod(defaults="fast",ss_x=1.0,ss_y=1.0,soothe=false,strength=80)


tweak(sat=1.1).WhiteBalance(y1=235,u1=113,v1=128)


thanks to all :thanks:

fvisagie
20th December 2014, 09:37
To my mind there's a strong likelihood that your sharpening results are adversely influenced by existing noise. To some extent noise artifacts will also be "sharpened", becoming more pronounced in the process as you have found.

If you have the time, it may be a good investment to rerun your sharpening evaluation after first adding some light-weight temporal denoising.

One light-weight denoiser you can try is HQDN3D(4.0, cs=3.0, lt=1.0, ct=4.5), and another light-weight sharpener to compare with the others is FFT3DFilter(bw=48, bh=48, bt=-1, ow=24, oh=24, sharpen=0.3). IIRC those are more-or-less the default parameters, but you should see what suits your video best, of course.

StainlessS
20th December 2014, 09:56
I believe that FluxSmooth is supposed to also be a fast temporal denoiser but I usually use either FFT3DFilter or HQDN3D as fvisagie suggests.
FFT3DFilter also has added advantage that it can (I think) differentiate between noise and detail edges and can simultaneously apply smoothing
to noise and sharpening to edge. FFT3DFilter is my usual Spatio/Temporal and VagueDenoise my favorite Spatial only denoiser.
(Of course MCDegrain is very nice too but a bit heavy duty).

MysteryX
21st December 2014, 01:20
Wow... with FFT3DFilter Denoise+Sharpen, not only is the quality much better, but the encoded file size went from 75MB to 66MB, which means less space is required to save the noise and I can afford to increase the encoding quality.

I added Denoise-only before resizing and Sharpen-only at the end.

Stormborec
21st December 2014, 02:02
I tested the FFT3Dfilter, but it's too slow for realtime playing.
I look again on the screenshots and i hesitate, if the sharpening actually makes sense ...
By use of most sharpeners the result looks a bit artifically /unnaturally.
If it sharpens edges, then it looks like cartoon movie, if it sharpens not-edges, then it enhances noise.
I think, it would be better to do something like sincresize, or just enhance local contrast.

Denoising is always detail loosing business. And the better (and slower) denoiser I use, the faster sharpener I have to use, due to playing in real time. And vice versa ...

http://www.imghosting.cz/images/9230.png (http://www.imghosting.cz/view-9230.png)

feisty2
21st December 2014, 06:58
sharpen an already denoised video can make it oil painted or plastic or whatever, unnatural anyway with a big chance
the better way to do it is sharpen the original noisy video, extract the dif, stabilize the dif so the noise, ringing kinda stuff would be gone, then apply the dif back to your source clip

MysteryX
21st December 2014, 08:22
Here's the result with Denoise/Sharpen after
http://s7.postimg.org/6i85blkfr/After.jpg (http://postimg.org/image/6i85blkfr/)

And with Denoise before resize, and Sharpen after
http://s17.postimg.org/lsz5x71t7/Before.jpg (http://postimg.org/image/lsz5x71t7/)

I'll stick with doing Denoise first.

feisty2
21st December 2014, 09:03
LWLibAVVideoSource("rule6")
dif=mt_makediff (sharpen (0.5),last).dfttest (sigma=128)
mt_adddiff (dif)
http://i.imgur.com/TCD2xF3.png
LWLibAVVideoSource("rule6")
dfttest ()
sharpen (0.5)
http://i.imgur.com/lNoPdgM.png

now now...

Stormborec
21st December 2014, 12:32
Maybe just sharpen() gives the most natural look ...

Or better resize*2 . sharpen . resize/2 ... but this is yet slower than LSFmod

Stormborec
21st December 2014, 13:28
http://www.imghosting.cz/images/7310.png (http://www.imghosting.cz/view-7310.png)

creaothceann
21st December 2014, 17:56
Why realtime?

Stormborec
21st December 2014, 19:26
http://www.ezoden.com/684/tutorial-htpc/9

MysteryX
21st December 2014, 19:37
If you want real-time optimization of your videos, why not use madVR?
http://forum.doom9.org/showthread.php?t=146228

Stormborec
21st December 2014, 21:19
madVR is question of dedicated GPU.
My computer has only integrated - the power is also quite limited.

Stormborec
21st December 2014, 22:37
What type of sharpening is actually the "sharpen()" in avisynth?
Is it some implementation of unsharp masking?

The "sharpen" in Virtualdub gives very similar results, but that in Avisynth amplifies less of noise.

StainlessS
21st December 2014, 22:54
Here on Wiki, http://avisynth.nl/index.php/Blur

This text is still present in v2.6 docs although removed from Wiki text.
A Known issue, with the MMX routines is the lack of full 8 bit precision in the calculations. This can lead to banding in the resultant image. Set the MMX=False option to use the slower but more accurate C++ routines if this is a concern.

Looks to have been fixed in v2.58.

Stormborec
22nd December 2014, 18:23
If I understand - the sharpen() is a kind of deconvolution ... something like xsharpen.
Here http://forum.doom9.org/showthread.php?s=&threadid=84196 is good description of different sharpeners, but already there are no pictures.

colours
22nd December 2014, 21:20
Avisynth's Blur/Sharpen use a three-tap convolution kernel horizontally and vertically and have nothing to do with deconvolution or unsharp masking.

The exact convolution kernel used by Sharpen(x) is [(1−2^x)/2, 2^x, (1−2^x)/2], in case you're interested in that. Blur(x) uses the same kernel but with x negated, i.e. [(1−2^−x)/2, 2^−x, (1−2^−x)/2].

(Why it is parametrised exponentially (a fact not even mentioned in the documentation) instead of linearly will remain a mystery forever more.)

Stormborec
22nd December 2014, 22:08
And difference between sharpen vs. xsharpen?

If I understand well - sharpen uses something like average of the 3×3, and xsharpen uses max./min. pixel of the 3×3 ...

What would you recommanded for SD films (DVDrips) ?
I think, DVDrips are often blurred before recompression, due to reducing of bitrate ...

feisty2
23rd December 2014, 06:08
search "FQSharp" if you think deconvolution is what you're looking for
it does produce very nice results as a sharpen kernel, but it's slow and complicated to use (it's just a "kernel", you can't use it directly without any other process and expect miracle from it)

Bloax
23rd December 2014, 17:49
Maybe just sharpen() gives the most natural look ...
If that was true we wouldn't have tons upon tons of different sharpening methods.

It could be that the test picture in question (you know the one (http://i.imgur.com/TCD2xF3.png)) is just very suited to naive sharpening, however - what with the high quality, high amount of softened details and barely any artifacts and all that. :^)

Stormborec
23rd December 2014, 18:25
I wrote about DVDrips, which are already degrained /blured before compression, due to lowering of bitrate.
It is true - there are better than sharpen(), but I doubt, that somewhat with similar speed.

feisty2:
dif=mt_makediff (sharpen (0.5),last).dfttest (sigma=128)
mt_adddiff (dif)


What about something like:

a=dfttest
dif=mt_makediff (last,a)
a.sharpen.mt_adddiff (dif)

feisty2
24th December 2014, 05:19
If that was true we wouldn't have tons upon tons of different sharpening methods.

It could be that the test picture in question (you know the one (http://i.imgur.com/TCD2xF3.png)) is just very suited to naive sharpening, however - what with the high quality, high amount of softened details and barely any artifacts and all that. :^)

hey, I was just demonstrating stabilize the sharp dif is better than sharp an already denoised clip I never said "sharpen (x)" is the best solution to all, it's just for a quick comparison, you can see I used the same "sharpen (0.5)" on both images

back to the point, "sharpen (x)" is actually a pretty good "kernel" for further more delicate process (spatial limit, temporal limit...) at least better than "removegrain (11)" which is widely used as a sharpen kernel, "sharpen (x)" is an accurate Gaussian filter, removegrain (11) is an approximate Gaussian filter, you need your convolution filter to be as accurate as possible if you want the final result looks natural
and the limit method, the lut limit expr is another thing matters, if you want things to be natural, use the lut expr here (http://forum.doom9.org/showthread.php?t=163598&highlight=detailsharpen) @ #4

feisty2
24th December 2014, 05:22
a very quick natural sharpen, here you go
o=last
mt_lutxy(o,o.blur (0.5),"x x y - abs 4 / 1 4 / ^ 4 * 1.51 * x y - x y - abs 1.001 + / * +",U=2,V=2)

effect on your sample
http://i.imgur.com/d3K65vQ.png

and don't ever use xsharpen sorta stuff on natural clips, it might be the most possible cause of unnatural look

Reel.Deel
24th December 2014, 09:59
a very quick natural sharpen, here you go
o=last
mt_lutxy(o,o.blur (0.5),"x x y - abs 4 / 1 4 / ^ 4 * 1.51 * x y - x y - abs 1.001 + / * +",U=2,V=2)


Original source for this method: http://forum.doom9.org/showthread.php?p=1547017#post1547017

Edit: my bad, complete missed that. I blame it on the red font. :)

feisty2
24th December 2014, 10:36
Original source for this method: http://forum.doom9.org/showthread.php?p=1547017#post1547017

Yeah, I posted the link at #33, the hyperlink "here" links to this

Stormborec
24th December 2014, 11:07
So, why Dideé uses removegrain instead of blur?

My question is:

LSFmod is in level of its speed maybe the best.
The reason why I search for something else is, that I need some more speed. I can use LSFmod(ss_x=1,ss_y=1) - but I'm sure, that it doesn't work optimally. The whole - very complex LSFmod script is without supersampling somewhat degraded and I think, that can be more suitable easier solutions.
One way is to do easy - sharpen(), or removegrain(), or something other, also very simple.
So, What is the solution with only of a bit speed penalty in comparisson with sharpen() - for "natural clips", DVDrips etc. ?

feisty2
24th December 2014, 11:13
script at #34 is very fast, even faster than realtime, and the result does look natural, and the quality is far better than single "sharpen (x)", free of ringing kinda stuff, I think it should be what you're looking for

edit:
So, why Dideé uses removegrain instead of blur?
no idea, removegrain (11) should be similar to blur (1) but slightly worse, due to the inaccuracy

colours
24th December 2014, 13:13
no idea, removegrain (11) should be similar to blur (1) but slightly worse, due to the inaccuracy

This is true, but let me highlight that RemoveGrain(11) is over five times as fast as Blur(1) while still having an error bounded by ±1. "Slightly worse", sure, but not a difference you should care about in most circumstances.

feisty2
24th December 2014, 13:28
This is true, but let me highlight that RemoveGrain(11) is over five times as fast as Blur(1) while still having an error bounded by ±1. "Slightly worse", sure, but not a difference you should care about in most circumstances.

blur (x) is already veeeerrrry fast, it wouldn't be the speed bottleneck of almost any process anyway, so why not use it instead, I did make a comparison between blur (1) and removegrain (11) unsharpen mask some time before, and I noticed blur (1) produces a little bit less ringing, but I couldn't tell any visual difference between single blur (1) and removegrain (11), so I think we should use sharpen (x) instead of removegrain (11) when sharpen is exactly what we are doing
edit:
and we can use radius less than 1.0 in blur, if we want to achieve blur (0.25) by removegrain (11), we're gonna have to do a 2x supersample

edit2:
never mind, to do blur (0.25) does need supersample, just not 2x, the math is wrong cuz I just noticed the radius parameter is not linear, that explains my forever confusion about why blur (-1) and mt_adddiff (mt_makediff (last,last.blur (1))) are so different

Stormborec
24th December 2014, 15:57
not linear - you mean the Sharpen(x) [(1−2^x)/2, 2^x, (1−2^x)/2] formula?

I'll test both, and I'll see ...

Is possible to do something similar with removegrain like the simple sharpen(x)? (I mean only luma processing, etc. - I'm a little confused from removegrain's manual ...)

I've tested the Dideé's (or feisty2's ?) "#33 sharpening", and it looks really great - the noise doesn't bother much ... :thanks:
I'll try compare their speed ...

But I'm sure I'll never understand what it means - the jumble of letters and numbers in mt_lutxy : D

btw. - where is the "strength parameter"?

Reel.Deel
24th December 2014, 16:36
btw. - where is the "strength parameter"?

The number 1.51 in the expression is the strength.

Stormborec
24th December 2014, 17:02
The result is also almost identical ...

feisty2
24th December 2014, 17:05
That expression is from SeeSaw
another sharpen script by didee
Seesaw and limitedsharp are aiming different goals
I think seesaw would be better for general purposes

Stormborec
24th December 2014, 17:17
Comparison:
mt_lutxy(last,last.removegrain(20)\
,"x x y - abs 4 / 1 4 / ^ 4 * 1.51 * x y - x y - abs 1.001 + / * +",U=2,V=2)\
http://www.imghosting.cz/images/3420.png (http://www.imghosting.cz/view-3420.png)

mt_lutxy(last,last.blur (0.5)\
,"x x y - abs 4 / 1 4 / ^ 4 * 2.10 * x y - x y - abs 1.001 + / * +",U=2,V=2)\
http://www.imghosting.cz/images/1521.png (http://www.imghosting.cz/view-1521.png)

(changed the "strength parameter" for the same sharpness)

Stormborec
24th December 2014, 17:21
Result in "punctuality or detailness?" is the same, "blur version" is much more less noisy, speed is nearly same ...

Stormborec
24th December 2014, 17:25
Seesaw needs a denoiser - then it is very slow. I don´t know, if it can be used properly without a denoiser.

feisty2
24th December 2014, 17:29
Removegrain(20)=blur(1.58) not blur (0.5) just so you know

Stormborec
24th December 2014, 18:04
OK, I changed only: the * 2.10 *

Now I see - with blur(1.58) and removegrain(20) - it's really nearly identical ...

Stormborec
24th December 2014, 18:09
btw. changing the number blur (is it strength?) I can change the level of noise ... so it's pretty tunable :D