Welcome to Doom9's Forum, THE inplace 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. 
9th June 2010, 08:58  #1  Link 
Registered User
Join Date: Feb 2004
Posts: 1,350

New Sharpening Function
Examples : 4x nnedi2, 4x nnedi2 New Sharpening, 4x nnedi2 limitedsharpenfaster smode4, 4x nnedi2 ssssharp.
Edit:Additional examples added, as requested. After reading this post by Didée I decided to take a crack at the problem of sharpening an interpolated or lowpassed image. Out of curiosity I tried the resulting function on a few difficult to sharpen noninterpolated sources (GITS R1 Special eddition, etc.), and it did very well (imo, of course). So here is a new, general sharpening function. Right now its named "blah". Because naming things is difficult, and naming it after what it is actually doing would require a paragraph long function call. Code:
Function blah(Clip c, Int "str", int "strv", int "strh", float "de", float "dev", float "deh", float "re", float "rev", float "reh", float "cstr", float "cstrv", float "cstrh") {# A sharpening function, Version 0.0 str = Default(Str, 4) strv = Default(strv, str) strh = Default(strh, str) de = Default(de, 0.2) dev = Default(dev, de) deh = Default(deh, de) re = Default(re, de/2) rev = Default(rev, re) reh = Default(reh, re) cstr = Default(cstr, 0.5) cstrv = Default(cstrv, cstr) cstrh = Default(cstrh, cstr) de = 20/de dev = 20/dev deh = 20/deh re = 20/re rev = 20/rev reh = 20/reh thrc = 72 thrcv = thrc thrcH = thrc thr2gv = 1/sqrt(thrcv) thr2gh = 1/sqrt(thrch) lp_V = C.NLLV_Variant4() Diff_V = mt_makediff(C, lp_V) lp_H = lp_V.NLLH_Variant4() Diff_H = mt_makediff(lp_V, lp_H) dev_ = string(rev) deh_ = string(reh) DeEmphasis = lp_H.yahr.yahr.Mt_Convolution(Horizontal=" 1 6 15 "+deh_+" 15 6 1 ", vertical =" 1 6 15 "+dev_+" 15 6 1 ", u=1, v=1) STRV_ = string(strv) Max_V = mt_luts( C, C, mode = "max", pixels = " 1 0 1 0 ", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+STRV_+" 1 >= "+STRV_+" 0.5 ^ "+STRV_+" ? + /  128 +", u=1, v=1) Min_V = mt_luts( C, C, mode = "min", pixels = " 1 0 1 0 ", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+STRV_+" 1 >= "+STRV_+" 0.5 ^ "+STRV_+" ? + /  128 +", u=1, v=1) MinMax_High_V = mt_lutXY( Max_V, Min_V, expr = "x 128  abs y 128  abs > x y ? 128  abs", u=1, v=1) MinMax_Low_V = mt_lutXY( Max_V, Min_V, expr = "x 128  abs y 128  abs > y x ? 128  abs", u=1, v=1) minmax_UL_V = mt_lutXY( MinMax_Low_V, MinMax_High_V, expr = "x y x  ", u=1, v=1) minmax_G_V = Average(MinMax_High_V, 0.1, MinMax_Low_V, 0.35, minmax_UL_V, 0.275, minmax_UL_V, 0.275) STRH_ = string(strh) Max_H = mt_luts( C, C, mode = "max", pixels = " 0 1 0 1 ", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+STRH_+" 1 >= "+STRH_+" 0.5 ^ "+STRH_+" ? + /  128 +", u=1, v=1) Min_H = mt_luts( C, C, mode = "min", pixels = " 0 1 0 1 ", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+STRH_+" 1 >= "+STRH_+" 0.5 ^ "+STRH_+" ? + /  128 +", u=1, v=1) MinMax_High_H = mt_lutXY( Max_H, Min_H, expr = "x 128  abs y 128  abs > x y ? 128  abs", u=1, v=1) MinMax_Low_H = mt_lutXY( Max_H, Min_H, expr = "x 128  abs y 128  abs > y x ? 128  abs", u=1, v=1) minmax_UL_H = mt_lutXY( MinMax_Low_H, MinMax_High_H, expr = "x y x  " ) minmax_G_H = Average(MinMax_High_H, 0.1, MinMax_Low_H, 0.35, minmax_UL_H, 0.275, minmax_UL_H, 0.275) Diff_V = mt_lutXY( Diff_V, minmax_G_V, expr = " x 128  y 1 > y 1 ? * y x 128  abs  1 > y x 128  abs  1 ? / 128 + ", u=1, v=1) Diff_H = mt_lutXY( Diff_H, minmax_G_H, expr = " x 128  y 1 > y 1 ? * y x 128  abs  1 > y x 128  abs  1 ? / 128 + ", u=1, v=1) Diff_HV = mt_adddiff(Diff_H, Diff_V) HPSharp = mt_adddiff(DeEmphasis, Diff_HV) rev_ = string(rev) reh_ = string(reh) ReEmphasis = HPSharp.Mt_Convolution(Horizontal=" 1 6 15 "+reh_+" 15 6 1 ", vertical =" 1 6 15 "+rev_+" 15 6 1 ", u=1, v=1) thrcv_ = string(thrcv) V = MT_Luts(ReEmphasis, ReEmphasis, mode="med", pixels = " 0 0 0 1 0 1 0 2 0 2 " ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrcv_+" 1 >= "+thrcv_+" 0.5 ^ "+thrcv_+" ? + /  128 +", u=1,v=1).mt_Lut("X 128  abs", u=1, v=1) thrch_ = string(thrch) H = MT_Luts(ReEmphasis, ReEmphasis, mode="med", pixels = " 0 0 1 0 1 0 2 0 2 0 " ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrch_+" 1 >= "+thrch_+" 0.5 ^ "+thrch_+" ? + /  128 +", u=1,v=1).mt_Lut("X 128  abs", u=1, v=1) Gauss_V = mt_Makediff(ReEmphasis, ReEmphasis.Mt_Convolution(Horizontal=" 1 ", vertical =" 1 6 15 20 15 6 1 ", u=1, v=1)) thr2gv_ = string(thr2gv) cstrv_ = string(cstrv) Gauss_V = mt_lutXY( Gauss_V, V, expr = " x 128  y * "+thr2gv_+" * "+cstrv_+" * 128 + ", u=1, v=1) Gauss_H = mt_Makediff(ReEmphasis, ReEmphasis.Mt_Convolution(Horizontal=" 1 6 15 20 15 6 1 ", vertical =" 1 ", u=1, v=1)) thr2gh_ = string(thr2gh) cstrh_ = string(cstrh) Gauss_H = mt_lutXY(Gauss_H, H, expr = " x 128  y * "+thr2gh_+" * "+cstrh_+" * 128 + ", u=1, v=1) Gauss_VH = mt_adddiff(Gauss_V, Gauss_H) contrast = mt_adddiff(ReEmphasis, Gauss_VH) Return(mergechroma(contrast, C, 1)) } Required Functions: Code:
Function blurH(clip c, int "rad", Float "CW") { Rad = Default(rad, 1) CW = Default(CW, 0.5) Center = C Left = C.PointResize(C.width, C.height, rad, 0, C.width, C.height) Right = C.PointResize(C.width, C.height, rad, 0, C.width, C.height) Average(Center, CW/2, Left, (1CW)/2, Right, (1CW)/2, Center, CW/2) Return(last) } Function BlurV(clip c, int "rad", Float "CW") { Rad = Default(rad, 1) CW = Default(CW, 0.5) Center = C Down = C.PointResize(C.width, C.height, 0, rad, C.width, C.height) Up = C.PointResize(C.width, C.height, 0, rad, C.width, C.height) Average(Center, CW/2, Down, (1CW)/2, Up, (1CW)/2, Center, CW/2) Return(last) } Function NLLH_Variant4(Clip C, int "rad") { Rad = Default(Rad, 1) B1 = C.BlurH(1*rad, 0.439) B2 = C.BlurH(2*rad, 0.833) B3 = C.BlurH(3*rad, 0.934) B4= C.BlurH(4*rad, 0.983) B1_D = Mt_Makediff(B1, C, u=1, v=1) B2_D = Mt_MakeDiff(C, B2, u=1, v=1) B3_D = Mt_MakeDiff(B3, C, u=1, v=1) B4_D = Mt_MakeDiff(C, B4, u=1, v=1) B2_DT = Mt_LutXY(B1_D, B2_D, " X 128  Y 128  X 128  abs Y 128  abs * 1 + * X 128  abs Y 128  abs * Y 128  abs 1.915 * X 128  abs  0 > \ Y 128  abs 1.915 * X 128  abs  0 ? X 128  abs 0 > X 128  abs 1 X 128  abs 0 > X 128  1 ? / ^ 1 ? / 1 * + 1 + / + 128 + ", u=1, v=1) B3_DT = Mt_LutXY(B2_DT, B3_D, " X 128  Y 128  X 128  abs Y 128  abs * 1 + * X 128  abs Y 128  abs * Y 128  abs 2.025 * X 128  abs  0 > \ Y 128  abs 2.025 * X 128  abs  0 ? X 128  abs 0 > X 128  abs 1 X 128  abs 0 > X 128  1 ? / ^ 1 ? / 1 * + 1 + / + 128 + ", u=1, v=1) B4_DT = Mt_LutXY(B3_DT, B4_D, " X 128  Y 128  X 128  abs Y 128  abs * 1 + * X 128  abs Y 128  abs * Y 128  abs 2.077 * X 128  abs  0 > \ Y 128  abs 2.077 * X 128  abs  0 ? X 128  abs 0 > X 128  abs 1 X 128  abs 0 > X 128  1 ? / ^ 1 ? / 1 * + 1 + / + 128 + ", u=1, v=1) Mt_AddDiff(B4_DT, C) Return(last) } Function NLLV_Variant4(Clip C, int "rad") { Rad = Default(Rad, 1) B1 = C.BlurV(1*rad, 0.439) B2 = C.BlurV(2*rad, 0.833) B3 = C.BlurV(3*rad, 0.934) B4= C.BlurV(4*rad, 0.983) B1_D = Mt_Makediff(B1, C, u=1, v=1) B2_D = Mt_MakeDiff(C, B2, u=1, v=1) B3_D = Mt_MakeDiff(B3, C, u=1, v=1) B4_D = Mt_MakeDiff(C, B4, u=1, v=1) B2_DT = Mt_LutXY(B1_D, B2_D, " X 128  Y 128  X 128  abs Y 128  abs * 1 + * X 128  abs Y 128  abs * Y 128  abs 1.915 * X 128  abs  0 > \ Y 128  abs 1.915 * X 128  abs  0 ? X 128  abs 0 > X 128  abs 1 X 128  abs 0 > X 128  1 ? / ^ 1 ? / 1 * + 1 + / + 128 + ", u=1, v=1) B3_DT = Mt_LutXY(B2_DT, B3_D, " X 128  Y 128  X 128  abs Y 128  abs * 1 + * X 128  abs Y 128  abs * Y 128  abs 2.025 * X 128  abs  0 > \ Y 128  abs 2.025 * X 128  abs  0 ? X 128  abs 0 > X 128  abs 1 X 128  abs 0 > X 128  1 ? / ^ 1 ? / 1 * + 1 + / + 128 + ", u=1, v=1) B4_DT = Mt_LutXY(B3_DT, B4_D, " X 128  Y 128  X 128  abs Y 128  abs * 1 + * X 128  abs Y 128  abs * Y 128  abs 2.077 * X 128  abs  0 > \ Y 128  abs 2.077 * X 128  abs  0 ? X 128  abs 0 > X 128  abs 1 X 128  abs 0 > X 128  1 ? / ^ 1 ? / 1 * + 1 + / + 128 + ", u=1, v=1) Mt_AddDiff(B4_DT, C) Return(last) } # Y'et A'nother H'alo R'educing script function YAHR(clip clp) { b1 = clp.minblur(2).removegrain(11,1) b1D = mt_makediff(clp,b1) w1 = clp.aWarpSharp(depth=32,blurlevel=2,thresh=0.5) w1b1 = w1.minblur(2,1).removegrain(11,1) w1b1D = mt_makediff(w1,w1b1) DD = b1D.repair(w1b1D,13) DD2 = mt_makediff(b1D,DD) clp.mt_makediff(DD2,U=2,V=2) } function MinBlur(clip clp, int r, int "uv") { uv = default(uv,3) uv2 = (uv==2) ? 1 : uv rg4 = (uv==3) ? 4 : 1 rg11 = (uv==3) ? 11 : 1 rg20 = (uv==3) ? 20 : 1 medf = (uv==3) ? 1 : 200 RG11D = (r==1) ? mt_makediff(clp,clp.removegrain(11,rg11),U=uv2,V=uv2) \ : (r==2) ? mt_makediff(clp,clp.removegrain(11,rg11).removegrain(20,rg20),U=uv2,V=uv2) \ : mt_makediff(clp,clp.removegrain(11,rg11).removegrain(20,rg20).removegrain(20,rg20),U=uv2,V=uv2) RG4D = (r==1) ? mt_makediff(clp,clp.removegrain(4,rg4),U=uv2,V=uv2) \ : (r==2) ? mt_makediff(clp,clp.medianblur(2,2*medf,2*medf),U=uv2,V=uv2) \ : mt_makediff(clp,clp.medianblur(3,3*medf,3*medf),U=uv2,V=uv2) DD = mt_lutxy(RG11D,RG4D,"x 128  y 128  * 0 < 128 x 128  abs y 128  abs < x y ? ?",U=uv2,V=uv2) clp.mt_makediff(DD,U=uv,V=uv) return(last) } Required plugins: Mt_Masktools, Average, Removegrain, aWarpSharp, Medianblur and Repair. Defaults are intended for strong sharpening on 2x upscaled material. For normal sharpening, set de to 0.02, str to 3 and cstr to 0.75 and go from there. The failure modes are as graceful as I can reasonably get them, considering the strength of the sharpening required. Also, the degree of sharpening that can be "gotten away with" varies pretty wildly by source. parameters: str = strength of highpass sharpening default 4 strv = vertical version of str defaults to str strh = horizontal version of str defaults to str de = deemphasis strength default 0.2 dev = vertical version of de defaults to de deh = horizontal version of de defaults to de re = reemphasis strength defaults to de/2 rev = vertical version of re defaults to re reh = horizontal version of re defaults to re cstr = strength of contrast sharpening default 1, values above 1 will cause halos cstrv = vertical version of cstr defaults to cstr cstrh = horizontal version of cstr defaults to cstr edit: thanks to Archimedes and Gavino for spotting two mistakes, both should now be fixed. edit2: Changed nonlinear lowpass function, new one should be generally more consistent Last edited by *.mp4 guy; 10th June 2010 at 23:47. 
9th June 2010, 15:03  #3  Link 
Registered User
Join Date: Apr 2005
Posts: 212

Requirements should be:
Code:
LoadPlugin("plugins\Average\src\Release\Average.dll") LoadPlugin("plugins\aWarpSharp\aWarpSharp.dll") LoadPlugin("plugins\MaskTools 2\mt_masktools.dll") LoadPlugin("plugins\MedianBlur\medianblur.dll") LoadPlugin("plugins\RemoveGrain 1.0\RemoveGrain.dll") LoadPlugin("plugins\RemoveGrain 1.0\Repair.dll") 
10th June 2010, 00:43  #6  Link 
ангел смерти
Join Date: Nov 2004
Location: Lost
Posts: 9,509

I always like your style, mp4 guy. Keep throwing luts at the problem, pare it down to what works, figure out why and use that to start the process again. I'll give this a shot tonight, though I have a feeling it's not going to work in realtime at all.
__________________
There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. 
16th June 2010, 03:22  #9  Link  
Registered User
Join Date: Feb 2004
Posts: 1,350

Quote:
Edit: Here is a question in return. Is the reduction in sharpening strength good or bad in your opinion? Last edited by *.mp4 guy; 16th June 2010 at 06:34. 

16th June 2010, 21:18  #10  Link 
Registered User
Join Date: Apr 2006
Posts: 296

I mostly use sharpening in avsynth on upscaled still images via FritzPhoto, much like the examples you posted.
I found the lack of texture was a let down to be honest. Also it seem to overemphasize speckle like features and "stray pixels". But then it's remarkably immune to halos so I'll keep my eye on any developments. 
18th June 2010, 10:26  #11  Link 
Registered User
Join Date: Feb 2004
Posts: 1,350

Alright, new spin off function. Pretty much just a general purpose sharpener now, but imo better then medsharp or sssharp. Also, better name then blah.
Code:
Function ReCon(clip c, float "str", float "strv", float "strh", float "rad", float "radh", float "radv", int "lmode", int "thresh") {#Reconvolution  makes things sharp by mixing pixels together str = Default(str, 4) strv = Default(strv, str) strh = Default(strh, str) Rad = Default(Rad, 2) Radv = Default(Radv, Rad) Radh = Default(Radh, Rad) lmode = Default(lmode, 1) thresh = Default(thresh, 720) thrc = thresh thrcv = thrc thrcH = thrc thr2gv = 1/sqrt(thrcv) thr2gh = 1/sqrt(thrch) str_ = thresh strv_ =str_ strh_ = str_ thrm = thresh thrm_ = string(thrm) Max_V = Radv == 0.5 ? mt_luts( C, C, mode = "max", pixels = "0 1 0 1", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : C Max_V = Radv == 1 ? mt_luts( C, C, mode = "max", pixels = "0 1 0 1 0 2 0 2", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Max_V Max_V = Radv == 1.5 ? mt_luts( C, C, mode = "max", pixels = "0 1 0 1 0 2 0 2 0 3 0 3", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Max_V Max_V = Radv == 2 ? mt_luts( C, C, mode = "max", pixels = "0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Max_V Max_V = Radv == 2.5 ? mt_luts( C, C, mode = "max", pixels = "0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Max_V Max_V = Radv == 3 ? mt_luts( C, C, mode = "max", pixels = "0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0 6 0 6", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Max_V Max_V = Radv == 4 ? mt_luts( C, C, mode = "max", pixels = "0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0 6 0 6 0 7 0 7 0 8 0 8", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Max_V Min_V = Radv == 0.5 ? mt_luts( C, C, mode = "min", pixels = "0 1 0 1", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : C Min_V = Radv == 1 ? mt_luts( C, C, mode = "min", pixels = "0 1 0 1 0 2 0 2", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Min_V Min_V = Radv == 1.5 ? mt_luts( C, C, mode = "min", pixels = "0 1 0 1 0 2 0 2 0 3 0 3", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Min_V Min_V = Radv == 2 ? mt_luts( C, C, mode = "min", pixels = "0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Min_V Min_V = Radv == 2.5 ? mt_luts( C, C, mode = "min", pixels = "0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Min_V Min_V = Radv == 3 ? mt_luts( C, C, mode = "min", pixels = "0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0 6 0 6", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Min_V Min_V = Radv == 4 ? mt_luts( C, C, mode = "min", pixels = "0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0 6 0 6 0 7 0 7 0 8 0 8", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Min_V thrcv_ = string(thrcv) Med_V = Radv == 0.5 ? MT_Luts(C, C, mode="med", pixels = "0 0 0 1 0 1" ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1,v=1) : C Med_V = Radv == 1 ? MT_Luts(C, C, mode="med", pixels = "0 0 0 1 0 1 0 2 0 2" ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1,v=1) : Med_V Med_V = Radv == 1.5 ? MT_Luts(C, C, mode="med", pixels = "0 0 0 1 0 1 0 2 0 2 0 3 0 3" ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1,v=1) : Med_V Med_V = Radv == 2 ? MT_Luts(C, C, mode="med", pixels = "0 0 0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4" ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1,v=1) : Med_V Med_V = Radv == 2.5 ? MT_Luts(C, C, mode="med", pixels = "0 0 0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5" ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1,v=1) : Med_V Med_V = Radv == 3 ? MT_Luts(C, C, mode="med", pixels = "0 0 0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0 6 0 6" ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1,v=1) : Med_V Med_V = Radv == 4 ? MT_Luts(C, C, mode="med", pixels = "0 0 0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0 6 0 6 0 7 0 7 0 8 0 8" ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1,v=1) : Med_V Med_V = Med_V.mt_Lut("X 128  abs", u=1, v=1) MinMax_High_V = mt_lutXY( Max_V, Min_V, expr = "x 128  abs y 128  abs > x y ? 128  abs", u=1, v=1) MinMax_Low_V = mt_lutXY( Max_V, Min_V, expr = "x 128  abs y 128  abs > y x ? 128  abs", u=1, v=1) minmax_UL_V = mt_lutXY( MinMax_Low_V, MinMax_High_V, expr = "x y x  ", u=1, v=1) minmaxmed_v = Average(MinMax_High_V, 0.0625, MinMax_Low_V, 0.25, minmax_UL_V, 0.34375, Med_V, 0.34375) STRH_ = string(strh_) Max_H = Radh == 0.5 ? mt_luts( C, C, mode = "max", pixels = "1 0 1 0", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : C Max_H = Radh == 1 ? mt_luts( C, C, mode = "max", pixels = "1 0 1 0 2 0 2 0", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Max_H Max_H = Radh == 1.5 ? mt_luts( C, C, mode = "max", pixels = "1 0 1 0 2 0 2 0 3 0 3 0", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Max_H Max_H = Radh == 2 ? mt_luts( C, C, mode = "max", pixels = "1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Max_H Max_H = Radh == 2.5 ? mt_luts( C, C, mode = "max", pixels = "1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Max_H Max_H = Radh == 3 ? mt_luts( C, C, mode = "max", pixels = "1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0 6 0 6 0", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Max_H Max_H = Radh == 4 ? mt_luts( C, C, mode = "max", pixels = "1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0 6 0 6 0 7 0 7 0 8 0 8 0", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Max_H Min_H = Radh == 0.5 ? mt_luts( C, C, mode = "min", pixels = "1 0 1 0", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : C Min_H = Radh == 1 ? mt_luts( C, C, mode = "min", pixels = "1 0 1 0 2 0 2 0", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Min_H Min_H = Radh == 1.5 ? mt_luts( C, C, mode = "min", pixels = "1 0 1 0 2 0 2 0 3 0 3 0", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Min_H Min_H = Radh == 2 ? mt_luts( C, C, mode = "min", pixels = "1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Min_H Min_H = Radh == 2.5 ? mt_luts( C, C, mode = "min", pixels = "1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Min_H Min_H = Radh == 3 ? mt_luts( C, C, mode = "min", pixels = "1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0 6 0 6 0", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Min_H Min_H = Radh == 4 ? mt_luts( C, C, mode = "min", pixels = "1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0 6 0 6 0 7 0 7 0 8 0 8 0", expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1, v=1) : Min_H thrch_ = string(thrch) Med_H = Radh == 0.5 ? MT_Luts(C, C, mode="med", pixels = "0 0 1 0 1 0" ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1,v=1) : C Med_H = Radh == 1 ? MT_Luts(C, C, mode="med", pixels = "0 0 1 0 1 0 2 0 2 0" ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1,v=1) : Med_H Med_H = Radh == 1.5 ? MT_Luts(C, C, mode="med", pixels = "0 0 1 0 1 0 2 0 2 0 3 0 3 0" ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1,v=1) : Med_H Med_H = Radh == 2 ? MT_Luts(C, C, mode="med", pixels = "0 0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0" ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1,v=1) : Med_H Med_H = Radh == 2.5 ? MT_Luts(C, C, mode="med", pixels = "0 0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0" ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1,v=1) : Med_H Med_H = Radh == 3 ? MT_Luts(C, C, mode="med", pixels = "0 0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0 6 0 6 0" ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1,v=1) : Med_H Med_H = Radh == 4 ? MT_Luts(C, C, mode="med", pixels = "0 0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0 6 0 6 0 7 0 7 0 8 0 8 0" ,expr = "X Y  X Y  X Y  abs 1 + * X Y  abs 1 + "+thrm_+" 1 >= "+thrm_+" 0.5 ^ "+thrm_+" ? + /  128 +", u=1,v=1) : Med_H Med_H = Med_H.mt_Lut("X 128  abs", u=1, v=1) MinMax_High_H = mt_lutXY( Max_H, Min_H, expr = "x 128  abs y 128  abs > x y ? 128  abs", u=1, v=1) MinMax_Low_H = mt_lutXY( Max_H, Min_H, expr = "x 128  abs y 128  abs > y x ? 128  abs", u=1, v=1) minmax_UL_H = mt_lutXY( MinMax_Low_H, MinMax_High_H, expr = "x y x  " ) minmaxmed_h = Average(MinMax_High_h, 0.0625, MinMax_Low_h, 0.25, minmax_UL_h, 0.34375, Med_h, 0.34375) Blur_V = C.NLLV_variant4() Blur_V = Rad > 1 ? Blur_V.NLLV_variant4(2) : Blur_V Blur_V = Rad > 2 ? Blur_V.NLLV_variant4(3) : Blur_V Blur_V = Rad > 3 ? Blur_V.NLLV_variant4(4) : Blur_V Sharp_Diff_V = mt_Makediff(C, Blur_V) thr2gv_ = string(thr2gv) cstrv_ = string(strv) Sharp_V = lmode == 0 ? mt_lutXY(Sharp_Diff_V, minmaxmed_v, expr = " x 128  y * "+thr2gv_+" * "+cstrv_+" * 128 + ", u=1, v=1) : C Sharp_V = lmode == 1 ? mt_lutXY(Sharp_Diff_V, minmaxmed_v, expr = " x 128  abs y > x 128  y * "+thr2gv_+" * "+cstrv_+" * 128 + X 128  y 0.5 ^ * "+thr2gv_+" 0.5 ^ * "+cstrv_+" * 128 + ? ", u=1, v=1) : Sharp_V Sharp_V = lmode == 2 ? mt_lutXY(Sharp_Diff_V, minmaxmed_v, expr = " x 128  abs y > x 128  y * "+thr2gv_+" * "+cstrv_+" * 128 + Y 0 > X 128  "+cstrv_+" * 128 + 128 ? ? ", u=1, v=1) : Sharp_V Sharp_V = lmode == 3 ? mt_lutXY(Sharp_Diff_V, minmaxmed_v, expr = " x 128  abs y > x 128  y * "+thr2gv_+" * "+cstrv_+" * 128 + X 128  "+cstrv_+" * 128 + ? ", u=1, v=1) : Sharp_V Sharp_V = lmode == 4 ? mt_lutXY(Sharp_Diff_V, minmaxmed_v, expr = " x 128  "+cstrv_+" * 128 + ", u=1, v=1) : Sharp_V Blur_H = C.NLLH_variant4() Blur_H = Rad > 1 ? Blur_H.NLLH_variant4(2) : Blur_H Blur_H = Rad > 2 ? Blur_H.NLLH_variant4(3) : Blur_H Blur_H = Rad > 3 ? Blur_H.NLLH_variant4(4) : Blur_H Sharp_Diff_H = mt_Makediff(C, Blur_H) thr2gh_ = string(thr2gh) cstrh_ = string(strh) Sharp_H = lmode == 0 ? mt_lutXY(Sharp_Diff_H, minmaxmed_h, expr = " x 128  y * "+thr2gh_+" * "+cstrh_+" * 128 + ", u=1, v=1) : C Sharp_H = lmode == 1 ? mt_lutXY(Sharp_Diff_H, minmaxmed_h, expr = " x 128  abs y > x 128  y * "+thr2gh_+" * "+cstrh_+" * 128 + X 128  y 0.5 ^ * "+thr2gh_+" 0.5 ^ * "+cstrh_+" * 128 + ? ", u=1, v=1) : Sharp_H Sharp_H = lmode == 2 ? mt_lutXY(Sharp_Diff_H, minmaxmed_h, expr = " x 128  abs y > x 128  y * "+thr2gh_+" * "+cstrh_+" * 128 + Y 0 > X 128  "+cstrh_+" * 128 + 128 ? ? ", u=1, v=1) : Sharp_H Sharp_H = lmode == 3 ? mt_lutXY(Sharp_Diff_H, minmaxmed_h, expr = " x 128  abs y > x 128  y * "+thr2gh_+" * "+cstrh_+" * 128 + X 128  "+cstrh_+" * 128 + ? ", u=1, v=1) : Sharp_H Sharp_H = lmode == 4 ? mt_lutXY(Sharp_Diff_H, minmaxmed_h, expr = " x 128  "+cstrh_+" * 128 + ", u=1, v=1) : Sharp_H Sharp_VH = mt_adddiff(Sharp_V, Sharp_H) sharpened = mt_adddiff(C, Sharp_VH) sharpened.mergechroma(C, 1) Return(last) } Rad  radius of sharpening str  strength lmode  limit mode, 0 strong limiting, 3 minimal limiting. Default 1. Also, I'm curious if rad 4 ever works better then rad 3. update: added lmode 4 Last edited by *.mp4 guy; 20th June 2010 at 07:35. 
19th June 2010, 17:17  #13  Link 
Registered User
Join Date: Apr 2006
Posts: 296

Been testing Recon on a few web sized digicam and camera phone photos and I'm finding results are really pleasant and settings are simple and intuitive. I can see my self reachng for ReCon for most photos now. I'll still use lsfmod and sssharp for difficult sources and maximizing texture respectively. ReCon is in my eye the better general purpose sharpener now. Hats off for you *.mp4 guy!

20th June 2010, 07:33  #15  Link 
Registered User
Join Date: Feb 2004
Posts: 1,350

Using a radius above 4 is not supported. If a radius above 4 is selected, mask generation is disabled (clip c is used instead). Radii above 4 are not supported because they become unusably slow, and the limiting method breaks down.
In this case, the blur is too much, and the limiting fails. In light of this I have added an unlimited mode, lmode=4, as upon further testing, the sharpening kernel performs better then unsharp masking on this source. try theses settings with the updated version: ReCon(rad=4, str=3, lmode=4) Also, let me restate, rads that are not equal to 0.5, 1, 1.5, 2, 2.5, 3 or 4 do not function properly. Last edited by *.mp4 guy; 20th June 2010 at 07:36. 
22nd June 2010, 07:32  #16  Link 
Registered User
Join Date: Apr 2006
Posts: 296

I like the lmode range in the updated version !
I tried the blurry butterfly photo wih the new version was ab improvement. But I'm guessing you'd have to downscale that image further for a 4 pixel radius to fit.... Rather than talking about my special case I want to report that ReCon seems susceptible to alising in some sources, more so than lsfmod and sssharp. Last edited by markanini; 22nd June 2010 at 07:58. 
22nd June 2010, 14:53  #18  Link  
Registered User
Join Date: Apr 2005
Posts: 212

Quote:
However, on such blurred sources, antialiasing with supersampling afterwards (e. g. with NNEDI2) is not bad at all (if supersampling beforehand isn't a choice). ReCon(rad=4, str=4, lmode=4) >> ReCon(rad=4, str=4, lmode=4) + NNEDI2 + Spline36Resize >> Last edited by Archimedes; 22nd June 2010 at 14:58. 

22nd June 2010, 15:41  #19  Link  
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,394

Quote:
Instead of source > upsize > filter > downsize one would do 1) source > upsize > filter 2) get difference(upsize,filtered) 3) source.apply(difference.downsize) This way, the supersampling process affects only (well, mostly) the difference of the filter, not the source material in itself.
__________________
 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!) 

22nd June 2010, 16:53  #20  Link 
Registered User
Join Date: Apr 2005
Posts: 212

Things can be so easy. That will minimize the blur causing by the interpolation (up and downscaling), indeed. But that's not the fly in the ointment (© http://www.leo.org). It's much more the "difference.downsize" which I dislike in combination with normal sharpening.

Thread Tools  Search this Thread 
Display Modes  

