ImageChops.difference() method –
This method is used to get the absolute value of the pixel-by-pixel difference between the two images.
Syntax: ImageChops.difference(image1, image2)
Parameters:
image1 first image
image2 second imageReturn Value: It returns an Image.
# This will import Image and ImageChops modules from PIL import Image, ImageChops # Opening Images im = Image. open (r "C:\Users\Admin\Pictures\download.png" ) im2 = Image. open (r "C:\Users\Admin\Pictures\images.PNG" ) # here getting absolute difference # of image1 and image2 im3 = ImageChops.difference(im, im2) # showing resultant image im3.show() |
Output:
Images Used:
Python PIL | ImageChops.add_modulo() and ImageChops.difference() method
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities.