Reputation: 17285
It seems that given a multi-channel image img
I cannot do this:
img *= cv::Scalar(1.5,0.5,2.1);
I'd like to scale each channel by a different float factor.
Is there a simple way to do this?
I could use cv::transform()
but that seems like overkill (I also obviously don't want to manually and explicitly iterate on all the pixels).
Any suggestions?
Upvotes: 2
Views: 2755
Reputation: 41765
You can use multiply
:
cv::Mat3b m = ... ;
cv::multiply(m, cv::Scalar(2, 3, 4), m);
or, as suggested by @AdiShavit:
cv::Mat3b m = ... ;
m = m.mul(cv::Scalar(2, 3, 4));
Upvotes: 6