Julius Julius - 7 months ago 55
C++ Question

Conditional assignment in c++ opencv

In Python with opencv/numpy (2D) arrays

A1, A2, B1, B2
I can do

A1[B1>B2] = A2[B1>B2]

That is, I can assign values to A1 from A2 in places based on a condition between the B arrays.

How can I do this in opencv in C++?
Is the fastest way to simply loop over the arrays, or is there a better way?

Thank you very much in advance.


Use mask.

Mat m=B1>B2;