Ask Your Question
0

Mat element wise multiplication 8UC1 x 8UC3

asked 2017-01-26 22:53:11 -0600

Nbb gravatar image

How do i multiple an single channel mat with a 3 channel mat element wise ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-01-27 01:35:51 -0600

berak gravatar image

both Mat's need the same number of channels for this, so you have to convert the 8UC1 one:

Mat uc1 = ...
Mat uc3;
cvtColor(uc1, uc3, COLOR_GRAY2BGR);

Mat res;
multiply(mat, uc3, res, CV_16UC3); // choose larger depth, to avoid saturation !
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-01-26 22:53:11 -0600

Seen: 1,366 times

Last updated: Jan 27 '17