Ask Your Question
0

How to subtract a constant from a 3 channel mat ?

asked 2017-01-11 04:24:36 -0600

Nbb gravatar image

updated 2017-01-11 04:25:14 -0600

I have a Mat CV_8UC3. I want to let the new value be

Mat = 255 - Mat;

but the results are blue. How do let every element be 255 - element ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-01-11 05:26:58 -0600

berak gravatar image

updated 2017-01-11 08:04:52 -0600

you need a 3-channel value to subtract from, else it does something like 0 - value, which gets saturated to 0, so:

1.

mat = Scalar(255,255,255) - mat;

2.

subtract(Scalar(255,255,255), mat, mat);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-01-11 04:24:36 -0600

Seen: 9,793 times

Last updated: Jan 11 '17