Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
8th April 2012, 13:04 | #2 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
Cracked up a function. Should work correctly, but more refinements about "usability" probably could be made. (In particular, there are no sanity checks for the parameters... - Quote IanB: "Give the user enough rope to hang himself" )
Required plugins: MaskTools, RemoveGrain, Repair. Code:
# Small and relatively fast realtime-sharpening function, # for 1080p, or after scaling 720p -> 1080p during playback (to make 720p look more like being 1080p) # It's a generic sharpener. Only for good quality sources! # (If the source is crap, FineSharp will happily sharpen the crap.) ;) # Noise/grain will be enhanced, too. The method is GENERIC. # # Modus operandi: A basic nonlinear sharpening method is performed, then the *blurred* sharp-difference gets subtracted again. # # - Didée function FineSharp(clip c, int "mode", float "sstr", float "cstr", float "xstr", float "lstr", float "pstr", float "ldmp") { mode = default(mode, 1 ) # 1 to 3, weakest to strongest. When negative -1 to -3, a broader kernel for equalisation is used. sstr = default(sstr, 2.0 ) # strength of sharpening, 0.0 up to ?? _cstr = spline(sstr, 0,0, 0.5,0.1, 1.0,0.6, 2.0,0.9, 2.5,1.00, 3.0,1.09, 3.5,1.15, 4.0,1.19, 8.0,1.249, 255.0,1.5) _cstr = (mode>0) ? _cstr : pow(_cstr,1./1.25) cstr = default(cstr, _cstr) # strength of equalisation, 0.0 to ? 2.0 ? (recomm. 0.5 to 1.25, default AUTO) xstr = default(xstr, 0.19 ) # strength of XSharpen-style final sharpening, 0.0 to 1.0 (but, better don't go beyond 0.249 ...) # Viscera parameters lstr = default(lstr, 1.49 ) # modifier for non-linear sharpening pstr = default(pstr, 1.272) # exponent for non-linear sharpening ldmp = default(ldmp, sstr+0.1) # "low damp", to not overenhance very small differences (noise coming out of flat areas) str1 = sstr str2 = cstr SSTR = string(sstr) CSTR = string(cstr) LSTR = string(lstr) PSTR = string(pstr) LDMP = string(ldmp) rg=mode>0?11:20 b = (abs(mode)==1) ? c.removegrain(11,-1).removegrain(4,-1) \ : (abs(mode)==2) ? c.removegrain(4,-1).removegrain(11,-1) \ : (abs(mode)==3) ? c.removegrain(4,-1).removegrain(11,-1).removegrain(4,-1) : c shrpD = mt_lutxy(c,b,"x y - abs "+LSTR+" / 1 "+PSTR+" / ^ "+SSTR+" * x y - x y - abs 0.001 + / * x y - 2 ^ x y - 2 ^ "+LDMP+" + / * 128 +") shrp = (str1<0.01) ? c : c.mt_adddiff(shrpD,U=2,V=2) shrp = (str2<0.01) ? shrp : shrp.mt_makediff(shrpD.mt_lut("x 128 - "+CSTR+" * 128 +").removegrain(rg,-1),U=2,V=2) shrp = (xstr<0.01) ? shrp \ : mt_lutxy(shrp,shrp.removegrain(20,-1),"x x y - 9.9 * +",U=2,V=2).repair(shrp,12,0).mergeluma(shrp,1.0-xstr) return(shrp) }
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) Last edited by Didée; 12th April 2012 at 14:07. |
8th April 2012, 15:09 | #3 | Link |
Registered User
Join Date: Dec 2007
Location: Germany
Posts: 632
|
Looks interesting. Didée, you say it's for HD sources of high quality, but what about SD sources of high quality? Is it a good idea to use this script with SD?
Can't test it right now, so I'm just asking without checking it myself. |
9th April 2012, 15:54 | #4 | Link |
Registered User
Join Date: Apr 2009
Posts: 142
|
@Didée
Pal your new sharpener scripts based in mt_lutxy are simply great. I using them since you posted a way to increase sharp on the inside of images and not borders... I have to test the ones posted in this topic VS the ones that you posted to create local constrast enhancement... I dont see reason to go back to LSF.. this new sharpener way is best good looking (for my taste). A little request.. can you post the scripts that you use daily for realtime playback. Im sure that we will learn so much with this info In my case I only apply framedoubling with SVP and then add your local contrast enhancement script |
9th April 2012, 17:16 | #5 | Link |
Registered User
Join Date: Apr 2009
Posts: 142
|
@didée
Im testing the "finesharp" script and the result is very similar to this old script that you posted and I continue using Code:
str =1.49 o = last b = o.removegrain(11).removegrain(4) mt_lutxy(o,b,"x x y - abs 4 / 1 1.4 / ^ 4 * "+string(str)+" * x y - x y - abs 0.9 + / * +",U=2,V=2) Code:
z = 6 # z = zero point p = 1.6 # p = power str = 1.0 # str = strength rad = 3.0 # radius for "gauss" o = last g = o.bicubicresize(round(o.width()/rad/4)*4,round(o.height()/rad/4)*4).bicubicresize(o.width(),o.height(),1,0) mt_lutxy(o,g,"x x y - abs "+string(z)+" / 1 "+string(p)+" / ^ "+string(z)+" * "+string(str)+" * x y - x y - abs 1.500 + / * +",U=2,V=2) Its posible to rewrite these two scripts into one to save cpu cycles? Im not sure if some processing is repeated twice or can be reused. @annovif for blueray content try these two scripts.. localcontrast mask and then the "finesharp" resize of didee.. for my taste it looks much better than using LSF Last edited by travolter; 9th April 2012 at 17:20. |
9th April 2012, 18:50 | #6 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
Compare to a comparison of two hifi-sets, fairly equal, one has slightly better sound fidelity, one has slightly less fidelity. If you cheat the comparison by upp'ing the volume of the slightly worse one, many people will conclude that the lesser-fidelity set sounds better. Simply because louder sounds better.
It's a similar story here. Sharpening and contrast enhancement do introduce "more energy" into the picture. Usually this is observed as being "better", simply because the picture is getting more "BOOM!". However, the well-trained eye often can see that enhancement is just that: an enhancement. The picture tends to get this "fat" unsharp-masking look. Some say "woot! Rulez!", others say "oh, the poorness". The operation of fineSharp can be looked at from two different angles. Basically it is a highpass-sharpener - perform sharpening, but don't use the lower frequencies of the obtained difference. Viewed from another angle, the operation is "energy conservation": perform sharpening, sample the introduced energy, and reduce the (blurred) local energy again, to keep local energy more close to the original. This way you don't get the "BOOM!" into the picture. But it avoids the dreaded "fat" unsharp-masking appearance. It largely depends on the source characteristics, and it largely depends on personal taste. (And even on your personal "state of the day" - today this may look better, but tomorrow the other one ...) To recap, the method really was born by the matter of 720p playeback. Many 1080p sources are so that you really can keep almost everything in just 720p. But for playback you need to upsample again, and that's where the problem lies. Even if it's only a faint effect, 720p scaled to 1080p looks like ... something that has been upscaled. That why the three-liner (now FineSharp) did creep into ffdshow's Avisynth tab: make 720p look a little more close to 1080p during playback. Enhance sharpness wile reducing or avoiding the "fattness" introduced by the upsampling.
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
9th April 2012, 19:55 | #7 | Link |
Registered User
Join Date: Apr 2009
Posts: 142
|
This FineSharp is working pretty good.. I have to test it with SD resized to 720.. and probably is so good as applied to 720->1080
Thanks for your explanations .. Agree that my "state of the day" varies on each day.. but this way of sharper catched me than the traditional ways of sharp edges.. (aliasing problems when abused is the mainly nightmare in HD content) |
12th April 2012, 14:12 | #10 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
I've just added the "ldmp" parameter ("low damp"). It mostly didn't bother me during realtime usage, but upon closer inspection of still snapshots, there really was quite some noise coming up in almost-flat areas.
Default values for "cstr" have been slightly modified too. (Less destructive now for too big sstr values - but you shouldn't go too high with sstr to start with.)
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
13th April 2012, 08:11 | #12 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
Did you change anything else at the same time? The script is structurally unchanged, and works for me. (Though, still running the 2009-09-19 build of 2.6 MT)
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
17th May 2012, 05:04 | #16 | Link |
Registered User
Join Date: Jun 2009
Posts: 13
|
I am encoding anime with crf 21.5 for small filesize and use LimitedSharpenFaster + FastLineDarkenMOD.
I wonder if Finesharp have the same effect as LimitedSharpenFaster? Should I change to Finesharp in my situation? Thanks in advance, I'm no good in this. |
18th June 2012, 11:45 | #18 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
Generally and technically, the difference is "first gaussian blur, then median filter" (mode 1) -vs.- "fist median filter, then gaussian blur" (mode 2). Due to the either-or nature of median, it changes the behaviour on certain pixel constellations (i.e. extremely fine/thin detail, or e.g. DCT artifacts).
On most sources, the differences between mode 1 and 2 are pretty minute. If you don't see a difference, then it doesn't matter. That simple. ___ There is no hard rule when artifacts start to appear. (Speaking strictly, artifacts are introduced already at the weakest notch.) Keep in mind that the apparent strength of sharpening, as well as introduction of artifacts, also depend strongly on the "cstr" value. If you want to get more "BOOM" into the picture, you should rather reduce cstr, instead of raising sstr by too much. Also, switching the cstr operation from gaussian-kernel (positive sstr) to box-kernel (negative sstr) can make some gentle difference.
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
18th June 2012, 15:07 | #19 | Link |
Registered User
Join Date: May 2012
Posts: 15
|
thanks Didée i will try...
this morning i have tried to set sstr=10 and i made some test with 1080p trailer, with prometeus's trailer looked amazing but with MIB 3 it was crappy. I don't know why because the bitrate is the same but the result was like night and day... Andrea |
18th June 2012, 15:37 | #20 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
Sure, sstr=10 is insane. The default settings for cstr are adaptive to sstr. Effectively, cstr is "tearing down again" sstr, by applying the reverse of sstr's lowpass. The higher you set sstr, the higher the default cstr-reduction will be. That's why you should rather decrease cstr, instead of increasing sstr.
And again, this filter is meant for realtime playback. Not for encoding. The filter cares a crap about small hi-frequency artifacts on a per-pixel level. During normal watching, you probably won't notice them anyway. The encoder, however, sees each and every darn pixel and has to deal with it.
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
Thread Tools | Search this Thread |
Display Modes | |
|
|