c – 我想在一个矩阵的一行中添加一个标量

我创建了一个m-by-n矩阵 Mat,我想在这个矩阵的一行中添加一个标量.为了向矩阵的所有元素添加标量,可以使用以下语句:A = b,其中A是Mat对象,b是标量.但是如果我想在这个矩阵的一行中添加一个标量,那么如何轻松地执行此操作呢?

image.row(i) += Scalar(...);


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