import cv2 image = cv2.imread("img.png") image = ~image cv2.imwrite("img_inv.png",image)
cv::Mat inverted = cv::Scalar(255, 255, 255) - img;