Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

opencv

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.

like image 989
Aly Avatar asked Mar 15 '13 17:03

Aly


People also ask

What is Convertscaleabs?

Scales, computes absolute values and converts the result to 8-bit. Namespace: OpenCvSharp.

What is scalar OpenCV?

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.

What is use of mat class in OpenCV?

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.


Video Answer


1 Answers

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;   
like image 81
cedrou Avatar answered Oct 25 '22 03:10

cedrou