timothybrooks / hdr-plus

HDR+ Implementation
MIT License
594 stars 201 forks source link

weight calculation of merge #60

Closed olivertai closed 4 years ago

olivertai commented 4 years ago

I was digging into the implementation of merge process and get confused with the following pieces.

Expr norm_dist = max(1, i32(dist) / factor - min_dist / factor);
weight(tx, ty, n) = select(norm_dist > (max_dist - min_dist), 0.f, 1.f / norm_dist);

Here, how the weights are calculated? If norm_dist has a maximal value of 1, then how could it be greater than max_dist-min_dist?

Expr val_00 = input(idx_0(x), idx_0(y), tile_0(x), tile_0(y));
Expr val_10 = input(idx_1(x), idx_0(y), tile_1(x), tile_0(y));
Expr val_01 = input(idx_0(x), idx_1(y), tile_0(x), tile_1(y));
Expr val_11 = input(idx_1(x), idx_1(y), tile_1(x), tile_1(y));

Secondly why are these vals calculated like this in spatial merging? I didn't find much information about spatial merging details in hdr+ paper, so I didn't really get the purpose of this implemetation. Is there any paper that I can refer to here? Thank you.