在图像处理中,自动曝光算法对于提升图像质量至关重要,特别是在光线变化复杂的环境下。本文将详细介绍并优化两种自动曝光算法:SaliencySA 和 ExtremeColorSA,通过调整曝光参数以适应不同的光照条件和颜色特性。
SaliencySA
SaliencySALuma=NormalizedWeightedSum(SaliencyLuma,FrameLumaBE16x16)
SaliencySATarget=[setparam/tr:lux]
SaliencySALumaWeight=[setparam/tr:lux+TriggerCtrlSaliencyValue]
SaliencySAFrameWeight=1-SaliencySALumaWeight
SaliencySAAdjRatioSaliency=SaliencySATarget/SaliencySALuma
SaliencySAAdjRatioHigh=[setparam/tr:lux]/SaliencyHighPCTLLuma
SaliencySAAdjRatioLow=[setparam/tr:lux]/SaliencyLowPCTLLuma
SaliencySAAdjRatioMin=Min(SaliencySAAdjRatioSaliency,1.0,[setparam/tr:lux+SaliencySAAdjRatioHigh])
SaliencySAAdjRatioMin=Max(SaliencySAAdjRatioSaliency*0.4,SaliencySAAdjRatioMin)
SaliencySAAdjRatioMax=Max(SaliencySAAdjRatioSaliency,[setparam/tr:lux+SaliencySAAdjRatioLow])
SaliencySAAdjRatioMax=Min(SaliencySAAdjRatioSaliency*1.5,SaliencySAAdjRatioMax)
SaliencySAAdjRatioSel=(SaliencySAAdjRatioMin*[setparam/tr:lux+SaliencySAAdjRatioSaliency])/(SaliencySAAdjRatioMax*[setparam/tr:lux+SaliencySAAdjRatioSaliency]
SaliencySAAdjRatioFSATgt=(SaliencySAAdjRatioSel*FrameSALuma)/FrameSATarget
SaliencySAAdjRatio=[setparam/tr:lux+SaliencySAAdjRatioFSATgt]*FrameSATarget/FrameSALuma
SaliencySA 算法主要基于图像的显著性(Saliency)和亮度(Luma)来调整曝光参数,以达到最佳的视觉效果。以下是该算法的详细优化步骤:
- 计算显著性亮度权重
SaliencySALuma = NormalizedWeightedSum(SaliencyLuma, FrameLumaBE16x16)
SaliencySALumaWeight = setparam['tr:lux'] + TriggerCtrlSaliencyValue
SaliencySAFrameWeight = 1 - SaliencySALumaWeight
这里,SaliencyLuma 表示图像的显著性亮度图,FrameLumaBE16x16 是图像块的亮度信息。通过调整显著性亮度的权重,可以更好地控制曝光调整的方向。 - 计算曝光调整比例
SaliencySATarget = setparam['tr:lux']
SaliencySAAdjRatioSaliency = SaliencySATarget / SaliencySALuma
SaliencySAAdjRatioHigh = setparam['tr:lux'] / SaliencyHighPCTLLuma
SaliencySAAdjRatioLow = setparam['tr:lux'] / SaliencyLowPCTLLuma
SaliencySAAdjRatioMin = min(SaliencySAAdjRatioSaliency, 1.0, setparam['tr:lux'] + SaliencySAAdjRatioHigh)
SaliencySAAdjRatioMin = max(SaliencySAAdjRatioSaliency * 0.4, SaliencySAAdjRatioMin)
SaliencySAAdjRatioMax = max(SaliencySAAdjRatioSaliency, setparam['tr:lux'] + SaliencySAAdjRatioLow)
SaliencySAAdjRatioMax = min(SaliencySAAdjRatioSaliency * 1.5, SaliencySAAdjRatioMax)
SaliencySAAdjRatioSel = (SaliencySAAdjRatioMin * (setparam['tr:lux'] + SaliencySAAdjRatioSaliency)) / (SaliencySAAdjRatioMax * (setparam['tr:lux'] + SaliencySAAdjRatioSaliency))
SaliencySAAdjRatioFSATgt = (SaliencySAAdjRatioSel * FrameSALuma) / FrameSATarget
SaliencySAAdjRatio = (setparam['tr:lux'] + SaliencySAAdjRatioFSATgt) * FrameSATarget / FrameSALuma
通过计算一系列调整比例,确保曝光调整既不过度也不过低,同时考虑了图像的高亮和低亮区域。
ExtremeColorSA
ExtremeColorSALuma=FrameSALuma
ExtremeColorSATarget=ExtremeColorFinalTarget
ExtremeColorGreemZoneSum=ExtremeGreenColorZone1Ratio+ExtremeGreenColorZone2Ratio+ExtremeGreenColorZone3Ratio
ExtremeColorLargestRatio=Largest(ExtremeRedColorRatio,ExtremeColorGreemZoneSum,ExtremeBlueColorRatio,0.0)
ExtremeColorRedTargetAdj=[setparam/tr:lux+ExtremeRedColorRatio]
ExtremeColorGreenTargetAdj=[setparam/tr:lux+ExtremeColorGreenZoneSum]
ExtremeColorBlueTargetAdj=[setparam/tr:lux+ExtremeColorBlueZoneSum]
ExtremeColorSmallestTargetAdj=Smallest(ExtremeColorRedTargetAdj,ExtremeColorGreenTargetAdj,ExtremeColorBlueTargetAdj,1.0)
ExtremeColorFinalTarget=FrameSATarget*ExtremeColorSmallestTargetAdj
ExtremeColorSAAdjRatio=ExtremeColorSATarget/ExtremeColorSALuma
ExtremeColorSA 算法专注于通过调整颜色通道(红、绿、蓝)的曝光目标来改善图像的色彩表现。首先,计算了绿色区域的权重总和和最大的颜色区域比例。其次,基于各颜色区域的相对重要性,调整每个颜色通道的目标曝光值。最终,根据调整后的颜色目标和当前颜色亮度,计算出颜色曝光调整。