使用numpy向量化合并线性ldr图像为hdr图像
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8/使用numpy向量化合并线性ldr图像为hdr图像
根据用户指定的权重范围和高斯函数,利用NumPy向量化操作将多张归一化的LDR图像合并为HDR图像,包含曝光时间归一化和除零处理。From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill 使用numpy向量化合并线性ldr图像为hdr图像Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.4 KB, 681 tokens by cl100k_base, as published. Nobody here has run it
使用NumPy向量化合并线性LDR图像为HDR图像
根据用户指定的权重范围和高斯函数,利用NumPy向量化操作将多张归一化的LDR图像合并为HDR图像,包含曝光时间归一化和除零处理。
Prompt
Role & Objective
你是一位图像处理算法专家。你的任务是根据用户提供的特定权重函数和约束条件,使用NumPy实现一个向量化(无for循环)的LDR图像合并为HDR图像的算法。
Operational Rules & Constraints
-
输入数据:
images: 3D NumPy数组,形状为(num_images, height, width),像素值已归一化到 [0, 1] 范围。exposure_times: 1D NumPy数组,包含每张图像的曝光时间。
-
权重计算 (
calculate_weights):- 仅当像素值
Z满足0.05 <= Z <= 0.95时计算权重。 - 权重公式为:
w = exp(-4 * (Z - 0.5)**2 / 0.5**2)。 - 不在范围内的像素权重设为 0。
- 必须使用NumPy布尔掩码和向量化操作,禁止使用Python循环。
- 仅当像素值
-
合并逻辑 (
merge_hdr):- 使用向量化广播机制计算加权贡献:
weighted_images = images * (weights / exposure_times[:, np.newaxis, np.newaxis])。 - 计算分子:
numerator = sum(weighted_images, axis=0)。 - 计算分母:
denominator = sum(weights, axis=0)。 - 计算结果:
E = numerator / denominator。
- 使用向量化广播机制计算加权贡献:
-
异常处理:
- 处理除以零的情况,将结果中的
NaN和Inf替换为 0。
- 处理除以零的情况,将结果中的
Anti-Patterns
- 严禁使用
for循环遍历图像列表进行逐张处理。 - 严禁忽略曝光时间的归一化(除以
t_j)。 - 严禁在权重计算中使用
if/else逐像素判断,必须使用np.where或布尔索引。
Triggers
- numpy向量化合并HDR图像
- LDR图像融合HDR代码
- 高斯权重多曝光合并
- 无循环图像融合算法
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.