I created a m-by-n matrix Mat
and I would like to add a scalar to just one row of this matrix. In order to add a scalar to all elements of the matrix, you can use the following statement: A += b
, where A
is a Mat
object and b
in a scalar. But if I wanted to add a scalar to just one row of this matrix, how to perform this operation just as easily?
This is very easy:
image.row(i) += Scalar(...);
Taken from docs:
There are many different ways to create a Mat object. The most popular options are listed below:
...
Construct a header for a part of another array. It can be a single row, single column, several rows, several columns, rectangular region in the array (called a minor in algebra) or a diagonal. Such operations are also O(1) because the new header references the same data. You can actually modify a part of the array using this feature
...
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