OpenCV: The easiest way to split Mat into a Scalar

I think this is pretty much in the title, obviously I can iterate and share. But I suppose there is a built-in way. I saw cvConvertScale , but this does not work with type cv::Mat .

+6
source share
1 answer

I know the scaling operation for multiplying 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; 
+17
source

All Articles