Ask Your Question
1

Swap black and white

asked 2018-04-02 04:38:45 -0600

Safa gravatar image

updated 2018-04-03 10:40:57 -0600

Hello, I'm using Canny edge detection in a c++ opencv project and the output is in black and white (the lines of the detected objects are in white and the background is black) I would like to know if it's possible to swap/reverse the 2 colors and if so is there a predefined method for it. Thank you for your help.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2018-04-02 04:41:18 -0600

berak gravatar image

you can use bitwise_not or the even shorter ~ operator:

Mat inverted = ~mat;
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-04-02 04:38:45 -0600

Seen: 10,288 times

Last updated: Apr 02 '18