我想从 wiki http://en.wikipedia.org/wiki/Color_balance实现一些白平衡算法
它们只是一些简单的矩阵操作 openCV 是否提供任何函数来对一组像素进行乘法运算,如下所示?
例如,2 x 2、3 通道 Mat A =
0 0 0 1 1 1
2 2 2 3 3 3
3 x 3, 1 通道 Mat B =
1 0 0
0 2 0
0 0 3
A x B = C 和 C =
0 0 0 1 2 3
2 4 6 3 6 9
我已经编写了一些通用函数来处理像素转换,但如果存在 openCV 的内置函数,我更喜欢它,因为 openCV 的函数可能会进行一些优化
template<typename T, typename UnaryFunctor>
void transform_channel(cv::Mat &src, int channel, UnaryFunctor functor)
{
int const channels = src.channels();
if(channels == 1 && src.isContinuous()){
return transform_continuous_channel<T>(src, functor);
}
for(int row = 0; row != src.rows; ++row)
{
auto dst_ptr = get_pointer<T>(src, row, channel);
for(int col = 0; col != src.cols; ++col){
*dst_ptr = functor(*dst_ptr);
dst_ptr += channels;
}
}
}