Log in

View Full Version : Which blur to use for Local Contrast Enhancement?


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.

Reel.Deel
8th August 2015, 00:23
Have you read the "Local Contrast Enhancement (http://forum.doom9.org/showthread.php?t=161986)" thread?


EDIT: Despite the text "Attachments Pending Approval", they are already clickable.
Not clickable here...

fvisagie
8th August 2015, 11:25
Have you read the "Local Contrast Enhancement (http://forum.doom9.org/showthread.php?t=161986)" thread?

I did do my homework ;). I didn't see these questions addressed there, at least not specifically enough to prevent me missing them.

Not clickable here...

Sorry about that. I uploaded .PNGs, which were then auto-converted to .JPGs and needed approval. Previously I was able to post .PNGs as is and they also didn't need approval.

Reel.Deel
15th August 2015, 16:47
This won't answer your questions but here's a video that I came across yesterday: Local contrast enhancement: gaussian vs. bilateral blurring (https://www.youtube.com/watch?v=Uj4cmXlezVc)

fvisagie
17th August 2015, 13:05
Thoughtfullness still appreciated. :thanks: