View Single Post
Old 18th November 2014, 22:48   #62  |  Link
Hotte
Registered User
 
Join Date: Oct 2014
Posts: 209
Summary of fine sharpening package for HD Material.

Thanks very much to feisty2 for his extensive help!

Step 1: Sharpen
The following simple but highly effective unsharp mask will emphasize only fine detail contrast for Full HD material and will add no edge halos if parameter w is set to low values. feisty2 suggested another very interesting approach with the dither-tool, but after extensive testing I came back to my first approach: It creates a tiny bit less halos / mid contrast, it is faster, it is simpler because it does not need dither. Code runs very fast. With multitasking put ahead you might process more than 35 fps (full HD) on a quadcore:

Code:
# Step 0: Multitasking options (Avisynth 2.6)

SetMemoryMax(1024)	    
SetMTMode(2,8)              # Try SetMTMode(3,8) if you run into troubles

# Step 1: Sharpen

AviSource("blabla.avi")
convertToYV12               # YV12 is needed by binomial blur  

s=100                           # strength of sharpen. If steps 2 and 3 are applied: try 80-100 (donīt go beyond). Step 1 only: try 40 to 70
w=4                             # width of sharpen. If steps 2 and 3 are applied: try 3-5. Step 1 only: try 1-2. Larger w = larger halos 

i=last.binomialBlur(varY=0.5, varC=0, Y=3, U=2, V=2,useMMX=true)
j=subtract(i,last).levels(0+s,1,255-s,0,255)
w=w*(128/s)
k=j.levels(127-w,1,128+w,127-w,128+w)
subtract(last,k)
Step 2: Remove edge halos
One optional single line helps to effectively remove remaining edge halos e.g. from preprocessing. Thanks Didier for this brilliant filter (that you should not forget to download from the avisynth pages). Setting supersampling (Parameter ss) to 1.5 rather than 1.0 will slow down processing-speed to 40% but helps a little with anti-aliasing (reduce stairs on linear structures).

Code:
DeHalo_alpha(highsens=100,ss=1.0)     # highsens adjusted to address larger halos and to nicely fit into the package
Step 3: Remove grain
This step slows down processing heavily (to some 4 fps) but helps a lot. Emphasizing fine detail might lead to fine grain flickering. Mdegrain averages out ("calms") fine grain using adjacent frames. There is no relevant drop of sharpness with that step. As additional gift Mdegrain also calms fine sensor chroma noise to make it considerably less obtrusive. Mdegrain also brings back a natural look to diffuse structures like clouds which could have been overstructured here and there by the sharpening process. Highly recommended!

Code:
super = MSuper(pel=2, sharp=1)
bv2 = MAnalyse(super, isb = true, delta = 2, overlap=4)
bv1 = MAnalyse(super, isb = true, delta = 1, overlap=4)
fv1 = MAnalyse(super, isb = false, delta = 1, overlap=4)
fv2 = MAnalyse(super, isb = false, delta = 2, overlap=4)
MDegrain2(super,bv1,fv1,bv2,fv2,thSAD=400)
You can do even more degraining by using MDegrain3 (see avisynth documentation) at the cost of even less processing speed, but I found that Mdegrain2 does a very good job already. Mdegrain3 can bring some very slight improvement to clips with strong sensor chroma noise.

Have fun with this package and thanks to all thread partcipants who had helped me so generously.

Last edited by Hotte; 18th November 2014 at 22:50.
Hotte is offline   Reply With Quote