Fitting camera response function (CRF) curve based on Robertson algorithm

The steps to implement the python code are as follows:

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()

According to this algorithm, you can substitute the multi-exposure pictures and exposure times you need, fit the CRF curve and display it.

Robertson's algorithm needs to be calculated independently on each color channel, so it requires a 3-channel response function.

responseRobertson is a three-dimensional array, where the third dimension corresponds to the color channels of the image (B, G, R). Therefore, the response function curve needs to be plotted separately for each color channel. This can be accomplished by plotting the response function of each channel in a loop.

 

Guess you like

Origin blog.csdn.net/yooniversity/article/details/132132388