fvisagie
7th August 2015, 17:50
On the one hand,
#Unsharpen (it will sharpen the image)
function unsharpen(clip c,float variance,float k)
{
blr=gaussianblur(c,vary=variance,varc=2,Y=3,U=2,V=2,border=1)
return yv12lutxy(blr,c,"y x - "+string(k)+" * y +",y=3,u=2,v=2)
}
from VariableBlur.txt uses GaussianBlur() (comparing results with the VariableBlur unsharp() plugin function, it seems that uses Gaussian blur too). On the other hand, in contrast enhancement discussions elsewhere on this forum MedianBlur() is mentioned and used.
Using this radius-variance relationship (https://en.wikipedia.org/wiki/Talk%3AGaussian_blur#Radius_again) to provide similar settings for comparing MedianBlur() and GaussianBlur() LCE outputs with the function
function unsharpenmod(clip c, float "variance", float "strength", bool "chroma", string "blurfn") {
variance = Default(variance, 128.0 )
strength = Default(strength, 0.2 )
chroma = Default(chroma , true )
blurfn = Default(blurfn , "gaussian")
vbU = chroma ? 3 : 1
vbV = vbU
radiusY = Round(Sqrt(variance)*Sqrt(Log(255)/Log(2)) - 1)
radiusU = chroma ? radiusY : -256
radiusV = radiusU
mtU = chroma ? 3 : 4
mtV = mtU
blurfn = blurfn == "gaussian" ? \
"gaussianblur(c, varY=" + String(variance) + ", varC=" + String(variance) + ", Y=3, U=" + String(vbU) + ", V=" + String(vbV) + ")" : \
blurfn == "median" ? \
"Medianblur(c, radiusY=" + String(radiusY) + ", radiusU=" + String(radiusU) + ", radiusV=" + String(radiusV) + ")" : \
"""Assert(false, "unsharpenmod: Invalid blur function")"""
blr = Eval(blurfn)
return mt_lutxy(blr, c, "y x - " + string(strength) + " * y +", y=3, u=mtU, v=mtV)
}
seems to indicate (see screenshots in attachments):
MedianBlur LCE creates less overshoot along edges (e.g. GaussianBlur lightening the sky around (951, 460))
MedianBlur LCE seems more prone to growing lighter areas (e.g. the light grey around (235, 400) being replaced with white)
GaussianBlur LCE enhances areas of low contrast better (e.g. the mountain range either side of (360, 360))
MedianBlur LCE enhances areas of higher contrast better (e.g. the mountain area around (1044, 555))
(All the above with chroma processing enabled, merely because the video I'm working on benefits from it.)
Is that assessment correct and complete (at least for chroma-enabled cases)? If not, what improvements are necessary?
What kind of blur is normally preferred for Local Contrast Enhancement, and why?
Thanks,
François
EDIT: Despite the text "Attachments Pending Approval", they are already clickable.
#Unsharpen (it will sharpen the image)
function unsharpen(clip c,float variance,float k)
{
blr=gaussianblur(c,vary=variance,varc=2,Y=3,U=2,V=2,border=1)
return yv12lutxy(blr,c,"y x - "+string(k)+" * y +",y=3,u=2,v=2)
}
from VariableBlur.txt uses GaussianBlur() (comparing results with the VariableBlur unsharp() plugin function, it seems that uses Gaussian blur too). On the other hand, in contrast enhancement discussions elsewhere on this forum MedianBlur() is mentioned and used.
Using this radius-variance relationship (https://en.wikipedia.org/wiki/Talk%3AGaussian_blur#Radius_again) to provide similar settings for comparing MedianBlur() and GaussianBlur() LCE outputs with the function
function unsharpenmod(clip c, float "variance", float "strength", bool "chroma", string "blurfn") {
variance = Default(variance, 128.0 )
strength = Default(strength, 0.2 )
chroma = Default(chroma , true )
blurfn = Default(blurfn , "gaussian")
vbU = chroma ? 3 : 1
vbV = vbU
radiusY = Round(Sqrt(variance)*Sqrt(Log(255)/Log(2)) - 1)
radiusU = chroma ? radiusY : -256
radiusV = radiusU
mtU = chroma ? 3 : 4
mtV = mtU
blurfn = blurfn == "gaussian" ? \
"gaussianblur(c, varY=" + String(variance) + ", varC=" + String(variance) + ", Y=3, U=" + String(vbU) + ", V=" + String(vbV) + ")" : \
blurfn == "median" ? \
"Medianblur(c, radiusY=" + String(radiusY) + ", radiusU=" + String(radiusU) + ", radiusV=" + String(radiusV) + ")" : \
"""Assert(false, "unsharpenmod: Invalid blur function")"""
blr = Eval(blurfn)
return mt_lutxy(blr, c, "y x - " + string(strength) + " * y +", y=3, u=mtU, v=mtV)
}
seems to indicate (see screenshots in attachments):
MedianBlur LCE creates less overshoot along edges (e.g. GaussianBlur lightening the sky around (951, 460))
MedianBlur LCE seems more prone to growing lighter areas (e.g. the light grey around (235, 400) being replaced with white)
GaussianBlur LCE enhances areas of low contrast better (e.g. the mountain range either side of (360, 360))
MedianBlur LCE enhances areas of higher contrast better (e.g. the mountain area around (1044, 555))
(All the above with chroma processing enabled, merely because the video I'm working on benefits from it.)
Is that assessment correct and complete (at least for chroma-enabled cases)? If not, what improvements are necessary?
What kind of blur is normally preferred for Local Contrast Enhancement, and why?
Thanks,
François
EDIT: Despite the text "Attachments Pending Approval", they are already clickable.