Python PIL | logical_xor() and invert() method
PIL.ImageChops.logical_xor() method applies Logical XOR between two images. At least one of the images must have mode “1”.
Image 1:

Image2:

Syntax: PIL.ImageChops.logical_xor(image1, image2)
Parameters:
image1: first image
image2: second imageReturn Type: Image
# Importing Image and ImageChops module from PIL package from PIL import Image, ImageChops # creating a image1 object im1 = Image.open(r"C:\Users\sadow984\Desktop\a2.PNG") .convert("1") # creating a image2 object im2 = Image.open(r"C:\Users\sadow984\Desktop\x5.PNG") .covert("1") # applying logical_xor method im3 = ImageChops.logical_xor(im1, im2) im3.show() |
Output:

PIL.ImageChops.invert() method invert an image (channel).
Syntax: PIL.ImageChops.invert(image)
Parameters:
image1: imageReturn Type: Image
# Importing Image and ImageChops module from PIL package from PIL import Image, ImageChops # creating a image1 object im1 = Image.open(r"C:\Users\sadow984\Desktop\a2.PNG") # applying invert method im3 = ImageChops.invert(im1) im3.show() |
Output:
Recommended Posts:
- numpy.invert() in Python
- Python | Ways to invert mapping of dictionary
- Node Jimp | invert
- C program to invert (making negative) an image content in PGM format
- class method vs static method in Python
- Python | os.dup() method
- Python | set() method
- Python | next() method
- Python | os.getgrouplist() method
- Python | os.WTERMSIG() method
- Python | sys.getallocatedblocks() method
- Python | os.setreuid() method
- Python | os.pipe() method
- Python | Tensorflow tan() method
- Python | os.openpty() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet



