FineSharp

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
 
(Examples: more examples)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{FilterCat|External_filters|Adjustment_filters|Sharpeners}}
+
{{FilterCat4|External_filters|Scripts|Adjustment_filters|Sharpeners}}
{{Filter|{{Author/Didee}}|v1.0 - Update 2012/04/12|[http://forum.doom9.org/showthread.php?p=1569035#post1569035 FineSharp]|Sharpeners|
+
{{Filter3
[[YV12]]
+
| {{Author/Didée}}
|}}
+
| 2012/04/12
 +
| [http://avisynth.nl/images/FineSharp.avsi FineSharp.avsi]
 +
| Sharpeners
 +
|
 +
|6=[http://forum.doom9.org/showthread.php?p=1569035 Doom9 Thread]}}
 +
<br>
 +
== Description ==
 +
Small and relatively fast realtime-sharpening function, for 1080p, or after scaling 720p -> 1080p during playback (to make 720p look more like being 1080p).<br>
 +
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.
  
== Abstract ==
+
Modus operandi: A basic nonlinear sharpening method is performed, then the *blurred* sharp-difference gets subtracted again. <br>
A quick sharpening filter by Didee for sharpening high quality content, such as Bluray.
+
<br>
 +
== Requirements ==
 +
* AviSynth 2.5.8 or [http://sourceforge.net/projects/avisynth2/ greater]
 +
* [[FAQ_different_types_content#How_do_I_recognize_progressive.2C_interlaced.2C_telecined.2C_hybrid_and_blended_content.3F|Progressive]] input only
 +
* Supported color formats: [[YV12]]
  
== The script ==
+
=== Required Plugins ===
Located [http://forum.doom9.org/showthread.php?p=1569035#post1569035 here].
+
Latest versions of the following filters are recommended unless stated otherwise.<br>
 +
*[[MaskTools2]]
 +
*<strike>RemoveGrain and Repair - part of the [[RemoveGrain v1.0b]] package.</strike>
 +
*[[RgTools]] - recommended drop-in replacement for RemoveGrain & Repair!
 +
Additional [[planar]] colorspaces are supported when using AviSynth 2.6, RgTools and appropriate MaskTools2.
 +
<br>
 +
<br>
  
And mirrored below in case of disaster (not guarranteed to be up to date, retrieved July 16th, 2012).
+
== [[Script variables|Syntax and Parameters]] ==
 +
:{{Template:FuncDef|FineSharp (''clip'' c, ''int'' "mode", ''float'' "sstr", ''float'' "cstr", ''float'' "xstr", ''float'' "lstr", ''float'' "pstr", ''float'' "ldmp")}}
 +
<br>
 +
::{{Par2|c|clip| }}
 +
::::Input clip.
 +
<br>
 +
::{{Par2|mode|int|1}}
 +
:::Range: 1 to 3
 +
::::1 to 3, weakest to strongest. When negative -1 to -3, a broader kernel for equalization is used.
 +
<br>
 +
::{{Par2|sstr|float|2.0}}
 +
:::Range: 0.0 up to ??
 +
::::Strength of sharpening.
 +
<br>
 +
::{{Par2|cstr|float|AUTO}}
 +
:::Range: 0.0 - 2.0 ?<br>
 +
::::Strength of equalization.
 +
::::Recommended value: 0.5 to 1.25
 +
::::If all settings are left at their default value then {{Template:FuncDef|cstr}}=0.9
 +
<br>
 +
::{{Par2|xstr|float|0.19}}
 +
:::Range: 0.0 - 1.0 (but, better don't go beyond 0.249 ...)<br>
 +
::::Strength of XSharpen-style final sharpening.
 +
<br>
 +
::{{Par2|lstr|float|1.49}}
 +
::::Modifier for non-linear sharpening.
 +
<br>
 +
::{{Par2|pstr|float|1.272}}
 +
::::Exponent for non-linear sharpening.
 +
<br>
 +
::{{Par2|ldmp|float|{{Template:FuncDef|sstr}}+0.1}}
 +
::::"low damp", to not overenhance very small differences (noise coming out of flat areas).
 +
::::If {{Template:FuncDef|sstr}} is left at its default value (2.0) then {{Template:FuncDef|ldmp}}=2.1
 +
<br>
 +
== Examples ==
 +
FineSharp with default settings:
 +
[[AviSource]]("Blah.avi")
 +
FineSharp(mode=1, sstr=2.0, cstr=0.9, xstr=0.19, lstr=1.49, pstr=1.272, ldmp=2.1)
  
<pre>
+
More examples:
# Small and relatively fast realtime-sharpening function,  
+
FineSharp(mode=2, sstr=2.0, cstr=1.3, xstr=0.0,  lstr=1.49, pstr=1.472, ldmp=4.2) ## moderate
# for 1080p, or after scaling 720p -> 1080p during playback (to make 720p look more like being 1080p)
+
FineSharp(mode=3, sstr=6.0, cstr=1.3, xstr=0.0, lstr=1.49, pstr=1.472, ldmp=9.2) ## strong
# It's a generic sharpener. Only for good quality sources!
+
<br>
# (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")
+
== Changelog ==
{
+
  Version        Date            Changes<br>
   
+
  2012/04/12      2012/04/12      - Added "ldmp" parameter, and slightly modified the (auto) cstr defaults<br>
mode = default(mode, 1  )  #  1 to 3, weakest to strongest. When negative -1 to -3, a broader kernel for equalisation is used.
+
  2012/04/08      2012/04/08      - Initial release
sstr  = default(sstr, 2.0 )   #  strength of sharpening, 0.0 up to ??
+
<br>
   
+
== External Links ==
_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)
+
* [http://forum.doom9.org/showthread.php?p=1569035 Doom9 Forum] - FineSharp discussion.
_cstr = (mode>0) ? _cstr : pow(_cstr,1./1.25)
+
* [http://forum.doom9.org/showthread.php?t=171346 Doom9 Forum] - FineSharp AviSynth script ported to MPC-HC Shaders + madVR.
 
+
<br>
cstr  = default(cstr, _cstr)  #  strength of equalisation, 0.0 to ? 2.0 ? (recomm. 0.5 to 1.25, default AUTO)
+
<br>
xstr  = default(xstr, 0.19 )  #  strength of XSharpen-style final sharpening, 0.0 to 1.0 (but, better don't go beyond 0.249 ...)
+
-----------------------------------------------
 
+
'''Back to [[External_filters#Sharpeners|External Filters]] &larr;'''
                            #  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)
+
}
+
</pre>
+

Latest revision as of 21:23, 5 October 2017

Abstract
Author Didée
Version 2012/04/12
Download FineSharp.avsi
Category Sharpeners
License
Discussion Doom9 Thread


Contents

[edit] Description

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.

[edit] Requirements

[edit] Required Plugins

Latest versions of the following filters are recommended unless stated otherwise.

Additional planar colorspaces are supported when using AviSynth 2.6, RgTools and appropriate MaskTools2.

[edit] Syntax and Parameters

FineSharp (clip c, int "mode", float "sstr", float "cstr", float "xstr", float "lstr", float "pstr", float "ldmp")


clip  c =
Input clip.


int  mode = 1
Range: 1 to 3
1 to 3, weakest to strongest. When negative -1 to -3, a broader kernel for equalization is used.


float  sstr = 2.0
Range: 0.0 up to ??
Strength of sharpening.


float  cstr = AUTO
Range: 0.0 - 2.0 ?
Strength of equalization.
Recommended value: 0.5 to 1.25
If all settings are left at their default value then cstr=0.9


float  xstr = 0.19
Range: 0.0 - 1.0 (but, better don't go beyond 0.249 ...)
Strength of XSharpen-style final sharpening.


float  lstr = 1.49
Modifier for non-linear sharpening.


float  pstr = 1.272
Exponent for non-linear sharpening.


float  ldmp = sstr+0.1
"low damp", to not overenhance very small differences (noise coming out of flat areas).
If sstr is left at its default value (2.0) then ldmp=2.1


[edit] Examples

FineSharp with default settings:

AviSource("Blah.avi")
FineSharp(mode=1, sstr=2.0, cstr=0.9, xstr=0.19, lstr=1.49, pstr=1.272, ldmp=2.1)

More examples:

FineSharp(mode=2, sstr=2.0,  cstr=1.3, xstr=0.0,  lstr=1.49, pstr=1.472, ldmp=4.2) ## moderate
FineSharp(mode=3, sstr=6.0,  cstr=1.3, xstr=0.0,  lstr=1.49, pstr=1.472, ldmp=9.2) ## strong

[edit] Changelog

Version         Date            Changes
2012/04/12 2012/04/12 - Added "ldmp" parameter, and slightly modified the (auto) cstr defaults
2012/04/08 2012/04/08 - Initial release


[edit] External Links

  • Doom9 Forum - FineSharp discussion.
  • Doom9 Forum - FineSharp AviSynth script ported to MPC-HC Shaders + madVR.




Back to External Filters

Personal tools