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

2020-08-10 07:57发布

问题:

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.

回答1:

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;   


标签: c++ opencv