基于Robertson算法拟合相机响应函数(CRF)曲线

python代码实现步骤如下:

import numpy as np
import cv2
import os
import matplotlib.pyplot as plt

# 读取多曝光图像
# ... (省略了读取图像的代码)

img_list =[……]

# 提取每个像素的曝光时间
exp_times = np.array([……], dtype=np.float32)

# 估计相机响应函数
calibrateRobertson = cv2.createCalibrateRobertson()
responseRobertson = calibrateRobertson.process(img_list, times=exp_times)

# 显示相机响应函数曲线
x = np.arange(0, 256)
for i in range(responseRobertson.shape[2]):
    y = responseRobertson[:, :, i].squeeze()
    plt.plot(x, y, label=f'Channel {i+1}')

plt.title('Robertson Camera Response Curve')
plt.xlabel('Pixel Value')
plt.ylabel('Log Exposure')
plt.legend()
plt.show()

根据该算法可以代入自己需要的多曝光图片和曝光时间,拟合出CRF曲线并显示出来。

Robertson算法需要在每个颜色通道上独立地进行计算,因此它需要一个3通道的响应函数。

responseRobertson是一个三维数组,其中第三个维度对应于图像的颜色通道(B, G, R)。因此,需要为每个颜色通道分别绘制响应函数曲线。可以通过在循环中绘制每个通道的响应函数曲线来实现这一点。

猜你喜欢

转载自blog.csdn.net/yooniversity/article/details/132132388