Camera ISP 之 镜头阴影矫正(lens_shading_correction)
1、Lens ShadingLens Shading指画面四角由于入射光线不足形成暗角同时由于不同频率的光折射率不同导致Color Shading因此需要进行镜头阴影矫正Lens Shading Correction) 。 Lens shading分为两种 luma shading和color shadingISP中该模块一般在OB和DPC的后面。luma shading由于凸透镜中心的聚光能力远大于其边缘从而导致Sensor中心的光线强度大于四周从而造成中心亮四周暗的现象。color shading由于入射光中不同波长的光折射率不同导致入射光中不同波长的光落在感光器件的不同位置上造成图像的色彩不均匀。Color Shading一般与镜头和sensor的CRA不匹配有关。Lens Shading校正前后示意图在实际使用中校正后边角Noise略大需要在边角亮度和Noise之间取一个平衡。在低光照条件下通常会让四周的亮度达到中心亮度的70%90%就可以了。环境色温的差异也会导致计算出LSC gain curve有所差异在调校IQ的过程中会计算多种色温的LSC gain curve然后在实际使用过程中动态的调整curve形状。2、矫正方法Shading的矫正方法目前主流有两种一种是同心圆法一种是网格法。同心圆法的流程为a、找到RGB三通道的圆心一般选择为同一个点b、以同心圆的形状将画面的中心和画面的边缘的三通道乘以不同的增益具体如下图所示一般来说考虑shading渐变的曲率从中心到边缘逐渐增大所以等增益曲线中心稀疏边缘密集。一般来说lens shading的增益最好不要超过2倍因为会引入噪声。下图为mesh shading的矫正方法同一个方格中的增益一致mesh的分布也是中心稀疏四角密集。同心圆矫正方法的优点是计算量小缺点是镜头若装配时稍有不对称则矫正失败网格矫正方法的优点是能够应对各种shanding情况缺点是运算量大。3、Python简易实现def distance_euclid(point1, point2): return math.sqrt((point1[0] - point2[0])**2 (point1[1]-point2[1])**2) def approximate_mathematical_compensation(self, params, clip_min0, clip_max65535): # parms: # parameters of a parabolic model y a*(x-b)^2 c # For example, params [0.01759, -28.37, -13.36] # Note: approximate_mathematical_compensation require less memory print(----------------------------------------------------) print(Running lens shading correction with approximate mathematical compensation...) width, height utility.helpers(self.data).get_width_height() center_pixel_pos [height/2, width/2] max_distance utility.distance_euclid(center_pixel_pos, [height, width]) # allocate memory for output temp np.empty((height, width), dtypenp.float32) for i in range(0, height): for j in range(0, width): distance utility.distance_euclid(center_pixel_pos, [i, j]) / max_distance # parabolic model gain params[0] * (distance - params[1])**2 params[2] temp[i, j] self.data[i, j] * gain temp np.clip(temp, clip_min, clip_max) return temp核心原理1、计算像素到中心的距离center_pixel_pos [height/2, width/2] # 图像中心点 max_distance distance to corner # 最远距离对角线的一半 # 对每个像素 distance 像素到中心的距离 / max_distance # 归一化距离 0-12、增益模型gain a * (distance - b)² c# 不同参数的效果 距离(distance) → 增益(gain) 中心(0) : a*(0-b)² c 中间(0.5) : a*(0.5-b)² c 角落(1) : a*(1-b)² c # 理想情况中心增益小边缘增益大 中心增益 1.0 边缘增益 2.0 # 角落需要更多补偿假设一个100x100的图像以下面参数为例# 模型: y a*(x-b)^2 c # 例如: params [0.01759, -28.37, -13.36] # 其中: params[0] 0.01759 # a: 抛物线的开口大小和方向 params[1] -28.37 # b: 顶点的水平偏移 params[2] -13.36 # c: 顶点的垂直偏移基准增益center [50, 50] max_dist 70.7 (对角线距离) # 计算几个点的增益 中心像素 (50,50): - distance 0/70.7 0 - gain 0.01759×(0 28.37)² - 13.36 0.01759 × 804.8569 - 13.36 0.79743287 角落像素 (100,100): - distance 70.7/70.7 1 - gain 0.01759×(128.37)² - 13.36 0.01759 × 862.5969 - 13.36 1.81307947效果展示beforeafterrefhttps://www.cnblogs.com/wnwin/p/11805901.htmlhttps://blog.csdn.net/yxyx13120297/article/details/85206426https://zhuanlan.zhihu.com/p/40572917
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2418677.html
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!