Ask Your Question
1

Swap black and white

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

Safa gravatar image

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

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 -0500

berak gravatar image

you can use bitwise_not or the even shorter ~ operator:

Mat inverted = ~mat;
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 5,849 times

Last updated: Apr 02 '18