OpenCV multiply scalar and a Matrix

Posted by jarjarbinks on Stack Overflow See other posts from Stack Overflow or by jarjarbinks
Published on 2010-05-23T00:52:49Z Indexed on 2010/05/23 1:00 UTC
Read the original article Hit count: 769

Filed under:
|
|
|
|

Hi,

I am trying to find the easiest way to add, subtract a scalar value with a opencv 2.0 cv::Mat class.

Most of the existing function allows only matrix-matrix and matrix-scalar operations.

I am looking for a scalar-matrix operations.

I am doing it currently by creating a temporary matrix with the same scalar value and doing required arithmetic operation. Example below..

Mat M(Size(100,100), CV_8U);
Mat temp = Mat::ones(100, 100, CV_8U)*255; 
M = temp-M;

But I think there should be better/easier ways to do it.

Any suggestions ?

© Stack Overflow or respective owner

Related posts about matrix

Related posts about opencv