opencv 自带了一个查找表函数,可以实现并行快速查找的运算。有GPU加速功能
void LUT_test()
{
Mat lookUpTable(1, 256, CV_8U);
uchar *ptr = lookUpTable.data;
for (int i=0; i<256; ++i)
ptr[i] = (i >> 1) << 1; //color reduce
cout << lookUpTable << endl;
Mat input, output(3,3,CV_8U);
input = (Mat_<uchar>(3,3) << 1, 2, 3, 4, 5, 6, 7, 8, 9);
cout << input << endl;
LUT(input, lookUpTable, output);
cout << output << endl;
}
604

被折叠的 条评论
为什么被折叠?



