Greetings!
Thanks for this implementation, I find that it successfully achieved what the OpenCV version currently does not, specifically with respect to proper weighting of saturated pixels.
To support, after some research, I have found an improvement.
Basically, for the current hdr_debvec( ) function, I kept on getting nasty response functions like this:
I realized that what is technically happening is downsampling of the pixel values, such that the pixels are averaged / interpolated across each other. This is very problematic in the case where the user has many, many saturated pixels: averaging these values will make them unsaturated, and create a false color in between.
I figured a more robust approach would be to instead just uniformly sample individual pixels across a grid of the image.
Here is how that changed my camera response function (3600 samples):
Here is the new implementation (not my best code but it works):
def hdr_debvec(img_list, exposure_times, number_of_samples_per_dimension=60):
B = [math.log(e,2) for e in exposure_times]
l = constant.L
w = [z if z <= 0.5*255 else 255-z for z in range(256)]
samples = []
width = img_list[0].shape[0]
height = img_list[0].shape[1]
width_iteration = width / number_of_samples_per_dimension
height_iteration = height / number_of_samples_per_dimension
w_iter = 0
h_iter = 0
Z = np.zeros((len(img_list), number_of_samples_per_dimension*number_of_samples_per_dimension))
for img_index, img in enumerate(img_list):
h_iter = 0
for i in range(number_of_samples_per_dimension):
w_iter = 0
for j in range(number_of_samples_per_dimension):
if math.floor(w_iter) < width and math.floor(h_iter) < height:
pixel = img[math.floor(w_iter), math.floor(h_iter)]
Z[img_index, i*j] = pixel
w_iter += width_iteration
h_iter += height_iteration
return response_curve_solver(Z, B, l, w)
Thanks again and great work.