Skip to content

Commit b87a8a5

Browse files
committed
Set LUT for Robertson weights function to zero on borders
1 parent 2055bcc commit b87a8a5

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

modules/photo/src/hdr_common.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,13 @@ Mat RobertsonWeights()
7373
{
7474
Mat weight(LDR_SIZE, 1, CV_32FC3);
7575
float q = (LDR_SIZE - 1) / 4.0f;
76+
float e4 = exp(4.f);
77+
float scale = e4/(e4 - 1.f);
78+
float shift = 1 / (1.f - e4);
79+
7680
for(int i = 0; i < LDR_SIZE; i++) {
7781
float value = i / q - 2.0f;
78-
value = exp(-value * value);
82+
value = scale*exp(-value * value) + shift;
7983
weight.at<Vec3f>(i) = Vec3f::all(value);
8084
}
8185
return weight;

modules/photo/test/test_hdr.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,12 @@ TEST(Photo_MergeRobertson, regression)
208208
vector<Mat> images;
209209
vector<float> times;
210210
loadExposureSeq(test_path + "exposures/", images, times);
211-
212211
Ptr<MergeRobertson> merge = createMergeRobertson();
213-
214212
Mat result, expected;
215213
loadImage(test_path + "merge/robertson.hdr", expected);
216214
merge->process(images, result, times);
217-
Ptr<Tonemap> map = createTonemap();
218-
map->process(result, result);
219-
map->process(expected, expected);
220215

221-
checkEqual(expected, result, 1e-2f, "MergeRobertson");
216+
checkEqual(expected, result, 5.f, "MergeRobertson");
222217
}
223218

224219
TEST(Photo_CalibrateDebevec, regression)
@@ -252,5 +247,5 @@ TEST(Photo_CalibrateRobertson, regression)
252247

253248
Ptr<CalibrateRobertson> calibrate = createCalibrateRobertson();
254249
calibrate->process(images, response, times);
255-
checkEqual(expected, response, 1e-3f, "CalibrateRobertson");
250+
checkEqual(expected, response, 1e-1f, "CalibrateRobertson");
256251
}

0 commit comments

Comments
 (0)