PIL.ImageChops.subtract() method subtracts 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”.
Syntax: PIL.ImageChops.subtract(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:

# 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 subtract method im3 = ImageChops.add(im1, im2, scale = 1.0, offset = 2) im3.show() |
Output:

# 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 subtract method im3 = ImageChops.add(im1, im2, scale = 1.0, offset = 2) im3.show() |
Output:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
- Python PIL | GaussianBlur() method
- Python PIL | Kernel() method
- Python PIL | BoxBlur() method
- Python PIL | getbands() method
- Python PIL | logical_and() and logical_or() method
- Python PIL | UnsahrpMask() method
- Python PIL | ImageChops.subtract() and ImageChops.subtract_modulo() method
- Python PIL | Image.crop() method
- Python PIL | ImageOps.expand() method
- Python PIL | ImageEnhance.Color() and ImageEnhance.Contrast() method
- Python PIL | ImageGrab.grabclipboard() method
- Python PIL | RankFilter() method
- Python PIL | ImageChops.screen() and ImageChops.offset() method
- Python PIL | MedianFilter() and ModeFilter() method
- Python PIL | Image.new() method
- Python PIL | getbands() and getextrema() method
- Python PIL | paste() and rotate() method
- Python PIL | ImageChops.darker() method
- Python PIL | Image.split() method
- Python PIL | ImageChops.add() 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.

