forked from Brick-Mover/RAISR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
81 lines (68 loc) · 2.31 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "RAISR.h"
#include <vector>
#include <iostream>
using namespace cv;
using namespace std;
//void foo(Mat img, int r, int c, bool mirror, int rot, int patchLen=5) {
// if (mirror) {
// flip(img, img, 1);
// c = img.cols - c - 1;
// }
// if (rot != -1)
// rotate(img, img, rot);
//
//
// Mat imgGx, imgGy;
// spatialGradient(img, imgGx, imgGy);
// imgGx.convertTo(imgGx, CV_64F);
// imgGy.convertTo(imgGy, CV_64F);
//
// if (rot == ROTATE_90_COUNTERCLOCKWISE) {
// int nc = r;
// r = img.cols - c - 1;
// c = nc;
// } else if (rot == ROTATE_90_CLOCKWISE) {
// int nr = c;
// c = img.rows - r - 1;
// r = nr;
// } else if (rot == ROTATE_180) {
// r = img.rows - r - 1;
// c = img.cols - c - 1;
// }
//
// Mat patchGx = imgGx(Range(r - patchLen/2, r + patchLen/2 + 1),
// Range(c - patchLen/2, c + patchLen/2 + 1)).clone();
// cout << r << " " << c << endl;
// debugMat(patchGx);
//}
int main(int argc, char** argv) {
string dirPath = "./train_images";
string outPath = "./result_images";
string filterPath = "./filters";
vector<Mat> imageList;
vector<string> imageNameList;
readListOfImage(dirPath, imageList, imageNameList);
RAISR model(imageList, 4, 11, 9);
// string filterFilePath = "./filters/2018_5_31_19_40_15_scale_2.filter";
// model.readInFilter(filterFilePath);
model.train();
model.writeOutFilter(filterPath);
dirPath = "./test_images";
imageList.clear();
imageNameList.clear();
readListOfImage(dirPath, imageList, imageNameList);
vector<Mat> downScaledImageList;
vector<Mat> cheapScaledImageList;
vector<Mat> RAISRImageList;
model.test(true, imageList, downScaledImageList, RAISRImageList, cheapScaledImageList,"None");
for(int i = 0; i < imageList.size(); i++){
string currentOutPath = outPath + "/cheapScale_"+ imageNameList[i];
imwrite(currentOutPath, cheapScaledImageList[i]);
currentOutPath = outPath + "/RAISR_" + imageNameList[i];
imwrite(currentOutPath, RAISRImageList[i]);
currentOutPath = outPath + "/downScaled_" + imageNameList[i];
imwrite(currentOutPath, downScaledImageList[i]);
}
}