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
.
Scales, computes absolute values and converts the result to 8-bit. Namespace: OpenCvSharp.
ScalarRepresents a 4-element vector. The type Scalar is widely used in OpenCV for passing pixel values. In this tutorial, we will use it extensively to represent BGR color values (3 parameters). It is not necessary to define the last argument if it is not going to be used.
The Mat class of OpenCV library is used to store the values of an image. It represents an n-dimensional array and is used to store image data of grayscale or color images, voxel volumes, vector fields, point clouds, tensors, histograms, etc.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With