📜  Python PIL | ImageChops.constant()

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

Python PIL | ImageChops.constant()

PIL 是Python Imaging Library,它为Python解释器提供了图像编辑功能。 Image模块提供了一个同名的类,用于表示 PIL 图像。该模块还提供了许多工厂函数,包括从文件加载图像和创建新图像的函数。

PIL.ImageChops.constant()用给定的灰度填充通道。

使用的图像:

# importing image object from PIL
from PIL import Image, ImageChops  
  
# creating an image object 
img = Image.open(r"C:\Users\System-Pc\Desktop\TREE.JPG") 
img1 = ImageChops.constant(img, 60) 
    
img1.show() 

输出:

另一个例子:拍摄另一张具有不同值的图像以查看灰度强度的变化。

使用的图像:

# importing image object from PIL
from PIL import Image, ImageChops  
  
# creating an image object 
img = Image.open(r"C:\Users\System-Pc\Desktop\rose.jpg") 
img1 = ImageChops.constant(img, 200) 
    
img1.show() 

输出: