Python PIL | ImageChops.add() method

PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The ImageChops module contains a number of arithmetical image operations, called channel operations (“chops”). These can be used for various purposes, including special effects, image compositions, algorithmic painting, and more.
PIL.ImageChops.add() method adds two images, dividing the result by scale and adding the offset. If omitted, scale defaults to 1.0, and offset to 0.0. At least one of the images must have mode “1”. And scale and offset can have different values also.

Syntax: PIL.ImageChops.add(image1, image2, scale=1.0, offset=0)

Parameters:
image1: first image
image2: second image
scale: numeric value
offset: numeric value

Return Type: Image

Image1:

Image2:



filter_none

edit
close

play_arrow

link
brightness_4
code

# 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")
  
# creating a image2 object
im2 = Image.open(r"C:\Users\sadow984\Desktop\x5.PNG")
  
# applying add method
im3 = ImageChops.add(im1, im2, scale = 1.0, offset = 2)
  
im3.show()

chevron_right


Output:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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")
  
# creating a image2 object
im2 = Image.open(r"C:\Users\sadow984\Desktop\x5.PNG")
  
# applying add method
im3 = ImageChops.add(im1, im2, scale = 4.0, offset = 4)
  
im3.show()

chevron_right


Output:

More values of scale and offset can be used for different purposes.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.