...
#include "opencv2/opencv.hpp" #include "opencv2/cuda.hpp" #include "opencv2\cudaarithm.hpp" #include <iostream> #include <time.h> using namespace std; using namespace cv; int main(int, char) { unsigned long AAtime = 0, BBtime = 0; unsigned char O[1000][1000] = { 1, 2, }; //very slow; AAtime = getTickCount(); for (int i = 0; i < 1000; ++i) { for (int j = 0; j < 1000; ++j) { int t = O[i][j] * 1.14; t = (t > 255) ? 255 : t; O[i][j] = t; } } BBtime = getTickCount(); printf("just loop %.5lf sec \n", (BBtime - AAtime) / getTickFrequency()); //chec //fast unsigned char LUT[256]; AAtime = getTickCount(); for (int i = 0; i < 256; ++i) { int t = i * 1.14; t = (t > 255) ? 255 : t; LUT[i] = t; } for (int i = 0; i < 1000; ++i) for (int j = 0; j < 1000; ++j) O[i][j] = LUT[O[i][j]]; BBtime = getTickCount(); printf("using lut %.5lf sec \n", (BBtime - AAtime) / getTickFrequency()); //chec return 0; }...
No comments:
Post a Comment