Tonemap as Algorithm
This commit is contained in:
@@ -70,6 +70,7 @@ TEST(Photo_HdrFusion, regression)
|
||||
vector<Mat> images;
|
||||
|
||||
ifstream list_file(fuse_path + "list.txt");
|
||||
ASSERT_TRUE(list_file.is_open());
|
||||
string name;
|
||||
float val;
|
||||
while(list_file >> name >> val) {
|
||||
@@ -110,48 +111,48 @@ TEST(Photo_HdrFusion, regression)
|
||||
|
||||
TEST(Photo_Tonemap, regression)
|
||||
{
|
||||
string folder = string(cvtest::TS::ptr()->get_data_path()) + "hdr/";
|
||||
vector<Mat>images(TONEMAP_COUNT);
|
||||
for(int i = 0; i < TONEMAP_COUNT; i++) {
|
||||
stringstream stream;
|
||||
stream << "tonemap" << i << ".png";
|
||||
string file_name;
|
||||
stream >> file_name;
|
||||
loadImage(folder + "tonemap/" + file_name ,images[i]);
|
||||
}
|
||||
Mat img;
|
||||
loadImage(folder + "rle.hdr", img);
|
||||
vector<float> param(1);
|
||||
param[0] = 2.2f;
|
||||
string test_path = string(cvtest::TS::ptr()->get_data_path()) + "hdr/tonemap/";
|
||||
|
||||
for(int i = 0; i < TONEMAP_COUNT; i++) {
|
||||
|
||||
Mat img;
|
||||
loadImage(test_path + "../rle.hdr", img);
|
||||
ifstream list_file(test_path + "list.txt");
|
||||
ASSERT_TRUE(list_file.is_open());
|
||||
|
||||
string name;
|
||||
while(list_file >> name) {
|
||||
Mat expected = imread(test_path + name + ".png");
|
||||
ASSERT_FALSE(img.empty()) << "Could not load input image " << test_path + name + ".png";
|
||||
Ptr<Tonemap> mapper = Tonemap::create(name);
|
||||
ASSERT_FALSE(mapper.empty()) << "Could not find mapper " << name;
|
||||
Mat result;
|
||||
tonemap(img, result, i, param);
|
||||
mapper->process(img, result);
|
||||
result.convertTo(result, CV_8UC3, 255);
|
||||
checkEqual(images[i], result, 0);
|
||||
checkEqual(expected, result, 0);
|
||||
}
|
||||
list_file.close();
|
||||
}
|
||||
|
||||
TEST(Photo_Align, regression)
|
||||
{
|
||||
const int TESTS_COUNT = 100;
|
||||
string folder = string(cvtest::TS::ptr()->get_data_path()) + "hdr/";
|
||||
string folder = string(cvtest::TS::ptr()->get_data_path()) + "shared/";
|
||||
|
||||
string file_name = folder + "exp_fusion.png";
|
||||
string file_name = folder + "lena.png";
|
||||
Mat img = imread(file_name);
|
||||
ASSERT_FALSE(img.empty()) << "Could not load input image " << file_name;
|
||||
cvtColor(img, img, COLOR_RGB2GRAY);
|
||||
|
||||
int max_bits = 6;
|
||||
int max_shift = 64;
|
||||
srand(time(0));
|
||||
int max_bits = 5;
|
||||
int max_shift = 32;
|
||||
srand(static_cast<unsigned>(time(0)));
|
||||
int errors = 0;
|
||||
|
||||
for(int i = 0; i < TESTS_COUNT; i++) {
|
||||
Point shift(rand() % max_shift, rand() % max_shift);
|
||||
Mat res;
|
||||
shiftMat(img, shift, res);
|
||||
Point calc = getExpShift(img, res, max_bits);
|
||||
ASSERT_TRUE(calc == -shift);
|
||||
errors += (calc != -shift);
|
||||
}
|
||||
ASSERT_TRUE(errors < 5);
|
||||
}
|
||||
|
Reference in New Issue
Block a user