Python PIL | ImageChops.add_modulo() and ImageChops.difference() method
Last Updated :
27 Jun, 2019
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities.
ImageChops.add_modulo() method –
This method is used to add two images without clipping them unlike ImageChops.add() which clips the images.
Syntax: ImageChops.add_modulo(image1, image2)
Parameters:
image1 is the first image
image2 is the second image
Return Value: It returns an Image.
Note: Both the images should be of same MODE.
from PIL import Image, ImageChops
im = Image. open (r "C:\Users\Admin\Pictures\download.png" )
im2 = Image. open (r "C:\Users\Admin\Pictures\images.PNG" )
im3 = ImageChops.add_modulo(im, im2)
im3.show()
|
Output:
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 image
Return Value: It returns an Image.
from PIL import Image, ImageChops
im = Image. open (r "C:\Users\Admin\Pictures\download.png" )
im2 = Image. open (r "C:\Users\Admin\Pictures\images.PNG" )
im3 = ImageChops.difference(im, im2)
im3.show()
|
Output:
Images Used:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...