Utkrist Adhikari Utkrist Adhikari - 1 year ago 150
C++ Question

Subtract a vector from each row of matrix in opencv?

I have a matrix or Mat object (say M), and a row vector ,also a Mat object (say V). I want to subtract V from each row of M. I cannot find anything elegent way in openCV to do that, other than writing a custom code myself. Any help?

Answer Source

How about minus row by row:

for (int r = 0; r < M.rows; ++r) {
    M.row(r) = M.row(r) - V;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download