Merge pull request #8717 from sovrasov:robertson_weight_change

pull/8788/head
Alexander Alekhin 8 years ago
commit 27649de50b
  1. 6
      modules/photo/src/hdr_common.cpp
  2. 9
      modules/photo/test/test_hdr.cpp

@ -74,9 +74,13 @@ Mat RobertsonWeights()
{ {
Mat weight(LDR_SIZE, 1, CV_32FC3); Mat weight(LDR_SIZE, 1, CV_32FC3);
float q = (LDR_SIZE - 1) / 4.0f; float q = (LDR_SIZE - 1) / 4.0f;
float e4 = exp(4.f);
float scale = e4/(e4 - 1.f);
float shift = 1 / (1.f - e4);
for(int i = 0; i < LDR_SIZE; i++) { for(int i = 0; i < LDR_SIZE; i++) {
float value = i / q - 2.0f; float value = i / q - 2.0f;
value = exp(-value * value); value = scale*exp(-value * value) + shift;
weight.at<Vec3f>(i) = Vec3f::all(value); weight.at<Vec3f>(i) = Vec3f::all(value);
} }
return weight; return weight;

@ -208,17 +208,12 @@ TEST(Photo_MergeRobertson, regression)
vector<Mat> images; vector<Mat> images;
vector<float> times; vector<float> times;
loadExposureSeq(test_path + "exposures/", images, times); loadExposureSeq(test_path + "exposures/", images, times);
Ptr<MergeRobertson> merge = createMergeRobertson(); Ptr<MergeRobertson> merge = createMergeRobertson();
Mat result, expected; Mat result, expected;
loadImage(test_path + "merge/robertson.hdr", expected); loadImage(test_path + "merge/robertson.hdr", expected);
merge->process(images, result, times); merge->process(images, result, times);
Ptr<Tonemap> map = createTonemap();
map->process(result, result);
map->process(expected, expected);
checkEqual(expected, result, 1e-2f, "MergeRobertson"); checkEqual(expected, result, 5.f, "MergeRobertson");
} }
TEST(Photo_CalibrateDebevec, regression) TEST(Photo_CalibrateDebevec, regression)
@ -252,5 +247,5 @@ TEST(Photo_CalibrateRobertson, regression)
Ptr<CalibrateRobertson> calibrate = createCalibrateRobertson(); Ptr<CalibrateRobertson> calibrate = createCalibrateRobertson();
calibrate->process(images, response, times); calibrate->process(images, response, times);
checkEqual(expected, response, 1e-3f, "CalibrateRobertson"); checkEqual(expected, response, 1e-1f, "CalibrateRobertson");
} }

Loading…
Cancel
Save