1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| """ Lofic HDR 原理:单次曝光实现高动态范围 """
import numpy as np
class LoficHDR: """ Lofic HDR 2.0 模拟 传统 HDR: 多次曝光合成 → 运动模糊 Lofic HDR: 单次曝光 + 溢出电容 → 无运动模糊 """ def __init__(self, full_well_high=4000, overflow_cap=60000): self.fw_high = full_well_high self.overflow = overflow_cap def simulate(self, scene_radiance: np.ndarray) -> dict: """ 模拟 Lofic HDR 成像 Args: scene_radiance: 场景辐照度 (0-1) Returns: {'hdr_image': array, 'dr_db': float} """ high_gain = np.clip(scene_radiance * self.fw_high, 0, self.fw_high) overflow = np.clip( scene_radiance * 60000 - self.fw_high, 0, self.overflow ) hdr = high_gain + overflow dr_db = 20 * np.log10(self.fw_high + self.overflow) return { 'hdr_image': hdr, 'high_gain': high_gain, 'overflow': overflow, 'dr_db': dr_db }
if __name__ == "__main__": lofic = LoficHDR() scene = np.array([0.01, 0.1, 0.5, 0.8, 0.95, 1.0]) result = lofic.simulate(scene) print(f"动态范围: {result['dr_db']:.1f} dB") for i, s in enumerate(scene): print(f" 辐照度 {s:.2f}: 高增益={result['high_gain'][i]:.0f}, " f"溢出={result['overflow'][i]:.0f}, HDR={result['hdr_image'][i]:.0f}")
|