OpenCV:Whats the easiest way to divide a Mat by a Scalar

c++, opencv

Solution

I know the scaling operation for a multiplication by a scalar:

cv::Mat M;
float alpha;
cv::Mat Result = M * alpha;

Let's try this:

cv::Mat Result = M / alpha;

Or:

float beta = 1.0f / alpha;
cv::Mat Result = M * beta;   

Problem

I think it's pretty much in the title, obviously I can iterate through and divide. But I assume there is an inbuilt way. I saw `cvConvertScale` but this does not work with type `cv::Mat`.

Original source