I would like to implement some white balance algorithms from wiki http://en.wikipedia.org/wiki/Color_balance
They are just some simple matrix manipulation Do openCV offer any functions to do some multiplication on a group of pixels like following?
example, 2 x 2, 3 channels Mat A =
0 0 0 1 1 1
2 2 2 3 3 3
3 x 3, 1 channels Mat B =
1 0 0
0 2 0
0 0 3
A x B = C and C =
0 0 0 1 2 3
2 4 6 3 6 9
I have wrote some generic functions to deal with pixel transformation but I would prefer the build in function of openCV if it exist since the functions of openCV may do some optimization
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;
}
}
}