YHistSA
YHistClampValue=YHistLowPctlLuma- [set param/tr:lux+lux]
YHistClampValue=Max(YHistClampValue,0.0)
YHistClampValue=Min(YHistClampValue,[setparam/tr:lux+lux])
HighPctlLumaTarget=Max(YHistHighPctlLuma,[setparam/tr:lux+lux])
HighPctlLumaRemoveOffset=YHistHighPctlLuma- YHistClampValue
YHistScaleValue=HighPctlLumaTarget/HighPctlLumaRemove
YHistScaleValue=Min(YHistScaleValue,1.25)
在YHistSA部分库北,我們主要對圖像的亮度直方圖進行動態(tài)調(diào)整航罗,以適應(yīng)不同的光照條件禀横。具體步驟如下:
- 計算亮度鉗制值:
YHistClampValue = YHistLowPctlLuma - [set param/tr:lux+lux]
YHistClampValue = Max(YHistClampValue, 0.0)
YHistClampValue = Min(YHistClampValue, [set param/tr:lux+lux])
這里,我們根據(jù)設(shè)定的光照參數(shù)調(diào)整亮度直方圖的低閾值粥血,并確保其值在合理范圍內(nèi)柏锄。 - 確定高亮目標(biāo)值:
HighPctlLumaTarget = Max(YHistHighPctlLuma, [set param/tr:lux+lux])
設(shè)定高亮部分的目標(biāo)亮度值,確保圖像的高光部分不會過曝复亏。 - 計算亮度縮放比例:
HighPctlLumaRemoveOffset = YHistHighPctlLuma - YHistClampValue
YHistScaleValue = HighPctlLumaTarget / HighPctlLumaRemoveOffset
YHistScaleValue = Min(YHistScaleValue, 1.25)
通過計算高亮部分的縮放比例趾娃,調(diào)整圖像的亮度分布,同時限制最大縮放比例以防止失真缔御。
BrightenImgSA:
BrightenImgSALuma=BrightenImgPCTLLuma
BrightenImgSATarget=[setparam/tr:lux+lux]
BrightenImgSAAdjRatioBright=BrightenImgSATarget/BrightenImgSALuma
BrightenImgSAAdjRatioSat=[setparam/tr:lux+lux]/BrightenImgSatPCTLLuma
BrightenImgSAAdjRatioMin=Min(BrightenImgSAAdjRatioBright,BrightenImgSAAdjRatioSat)
BrightenImgSAAdjRatioFSATgt=BrightenImgSAAdjRatioMin*FrameSALum/FrameSATarget
BrightenImgSAAdjInc=BrightenImgSAMinRatio*((BrightenImgSAAdjRatioFSATgt-1)*[setparam/tr:lux+CtrlLuma])+1
BrightenImgSAMinRatio=Min([setparam/tr:lux+BrightenImgStatsRoughness],[setparam/tr:lux+BrightenImgFlatRatio])
BrightenImgSAAdjRatioFSATgt=(BrightenImgSAAdjRatioFSATgt>1)?BrightenImgSAAdjInc:BrightenImgSAAdjRatioFSATgt
BrightenImgSAAdjRatio.Start=[setparam/tr:lux+BrightenImgSAAdjRatioFSATgt]*FrameSATarget/FrameSALum
BrightenImgSAAdjRatio.End=256
在BrightenImgSA部分抬闷,我們專注于根據(jù)光照條件動態(tài)調(diào)整圖像的亮度和飽和度,以提升視覺質(zhì)量耕突。
初始化亮度和飽和度調(diào)整比例:
BrightenImgSALuma = BrightenImgPCTLLuma
BrightenImgSATarget = [set param/tr:lux+lux]
BrightenImgSAAdjRatioBright = BrightenImgSATarget / BrightenImgSALuma
BrightenImgSAAdjRatioSat = [set param/tr:lux+lux] / BrightenImgSatPCTLLuma
分別計算基于亮度和飽和度的調(diào)整比例笤成。確定最小調(diào)整比例:
BrightenImgSAAdjRatioMin = Min(BrightenImgSAAdjRatioBright, BrightenImgSAAdjRatioSat)
取亮度和飽和度調(diào)整比例中的較小值,作為最終的調(diào)整基準(zhǔn)眷茁。計算幀級別的調(diào)整目標(biāo)和增量:
BrightenImgSAAdjRatioFSATgt = BrightenImgSAAdjRatioMin * FrameSALum / FrameSATarget
BrightenImgSAMinRatio = Min([set param/tr:lux+BrightenImgStatsRoughness], [set param/tr:lux+BrightenImgFlatRatio])
BrightenImgSAAdjInc = BrightenImgSAMinRatio * ((BrightenImgSAAdjRatioFSATgt - 1) * [set param/tr:lux+CtrlLuma]) + 1
根據(jù)幀級別的亮度和目標(biāo)值炕泳,計算調(diào)整增量。應(yīng)用調(diào)整比例:
BrightenImgSAAdjRatioFSATgt = (BrightenImgSAAdjRatioFSATgt > 1) ? BrightenImgSAAdjInc : BrightenImgSAAdjRatioFSATgt
BrightenImgSAAdjRatio.Start = [set param/tr:lux+BrightenImgSAAdjRatioFSATgt] * FrameSATarget / FrameSALum
BrightenImgSAAdjRatio.End = 256
如果調(diào)整后的目標(biāo)比例大于1上祈,則應(yīng)用調(diào)整增量培遵;否則保持原比例。最后登刺,設(shè)置調(diào)整比例的起始和結(jié)束值籽腕。