简体   繁体   English

计算两幅图像的异或

[英]Calculating XOR of the two images

I came across the following function to calculate the XOR of 2 images.我遇到了以下 function 来计算 2 个图像的 XOR。 Could someone please explain to me what is actually happening here?有人可以向我解释这里实际发生了什么吗? Also, how is it different from the inbuilt function with Pillow logical_xor ?此外,它与带有 Pillow logical_xor的内置 function 有何不同?

 from PIL import Image, ImageChops

 def get_xor(image_1, image_2):

    i1 = ImageChops.invert(image_1)
    i2 = ImageChops.invert(image_2)

    return ImageChops.invert(ImageChops.add(ImageChops.subtract(i2, i1), ImageChops.subtract(i1, i2)))

Pillow logical XOR枕头逻辑异或

Logical XOR between two images.两个图像之间的逻辑异或。 At least one of the images must have mode “1” .至少其中一个图像必须具有模式“1”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM