Julius Julius - 1 year ago 136
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.

Answer Source

Use mask.

Mat m=B1>B2;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download