📜  Python PIL | ImageChops.darker() 方法

📅  最后修改于: 2022-05-13 01:55:41.433000             🧑  作者: Mango

Python PIL | ImageChops.darker() 方法

PIL 是Python Imaging Library,它为Python解释器提供了图像编辑功能。

ImageChops.darker()方法用于逐像素比较两个图像,并返回包含较暗值的新图像。

代码#1:

# importing Image class from PIL package
from PIL import ImageChops, Image
  
# opening images to compare
im1 = Image.open(r"C:\Users\Admin\Pictures\download.png")
im2 = Image.open(r"C:\Users\Admin\Pictures\images.png")
  
# Checking and returning a copy
# of image contating darker pixels
im = ImageChops.darker(im1, im2)
  
# showing image
im.show()

输出:

代码#2:

# importing Image class from PIL package
from PIL import ImageChops, Image
  
# opening images to compare
im1 = Image.open(r"C:\Users\Admin\Pictures\geeks.png")
im2 = Image.open(r"C:\Users\Admin\Pictures\capture.png")
  
# Checking and returning a copy
# of image contating darker pixels
im = ImageChops.darker(im1, im2)
  
# showing image
im.show()

输出:

注意:不要与Image.blend()方法混淆。这个方法完全不同