Skip to content

Instantly share code, notes, and snippets.

@lotusirous
Created July 31, 2021 10:08
Show Gist options
  • Save lotusirous/d056b41bf3ad7f4274acbd99cce9ff48 to your computer and use it in GitHub Desktop.
Save lotusirous/d056b41bf3ad7f4274acbd99cce9ff48 to your computer and use it in GitHub Desktop.
Xor 2 images with python
from cv2 import cv2
foo = cv2.imread("./foo.png")
bar = cv2.imread("./bar.png")
key = cv2.bitwise_xor(foo, bar)
cv2.imshow("xored data", key)
@Qu1ck5h0t
Copy link

Qu1ck5h0t commented Jan 30, 2025

Code doesn't work anymore, not on python3 at least. Here's the fix:

import cv2

foo = cv2.imread("./foo.png")
bar = cv2.imread("./bar.png")

key = cv2.bitwise_xor(foo, bar)
cv2.imshow("xored data", key)
cv2.waitKey(0)

@lotusirous
Copy link
Author

Thanks for your feedback. It may different in cv2 version :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment