A S
A S

Reputation: 2974

How to set Mat to Mat with a mask? (opencv)

I want to set certain pixels in a Mat to be equal to those in another Mat, according to a mask.
similar to this matlab code:

A(mask==1) = B(mask==1)  

How do I do it in OpenCV?

comment- using OpenCV 2.4.3

Upvotes: 2

Views: 662

Answers (1)

sietschie
sietschie

Reputation: 7543

You can use the copyTo function:

B.copyTo(A, mask)

Upvotes: 6

Related Questions