遍历图片推荐使用CV_EXPORTS_W void LUT(InputArray src, InputArray lut, OutputArray dst);
#include <opencv2\opencv.hpp>
#include <opencv2\core.hpp>
#include <iostream>
using namespace cv;
using namespace std;
Mat& ScanImageAndReduceC(Mat& I, const uchar* table);
Mat& ScanImageAndReduceIterator(Mat& I, const uchar* table);
Mat& ScanImageAndReduceRandomAccess(Mat& I, const uchar * table);
int ScanImg(int argc, char** argv)
{
Mat image, outImage;
image = imread("JayChou.jpg");
if (image.empty()) {
cout << "jpg couldn't to be load" << endl;
return -1;
}
int divideWidth = 10;
uchar table[256] = {0};
for (int i = 0; i < 256; i++) {
table[i] = (uchar)(divideWidth * (i / divideWidth));
}
const int times = 100;
double t = 0;
t = (double)getTickCount();
for (int i = 0; i < times; i++) {
Mat clone_i = image.clone();
outImage = ScanImageAndReduceC(clone_i, table);
}
t = 1000*((double)getTickCount() - t) / getTickFrequency();
t = t / times;
cout << "Time of reducing with the C operator [] (averaged for "
<< times << " runs): " << t << " milliseconds."<< endl;
t = (double)getTickCount();
for (int i = 0; i < times; i++) {
Mat clone_i = image.clone();
outImage = ScanImageAndReduceIterator(clone_i, table);
}
t &#