PIL是Python Imaging Library,它为python解释器提供了图像编辑函数。 ImageOps模块包含许多“现成的”图像处理操作。该模块有些实验性,大多数操作员只能处理L和RGB图像。
ImageOps.posterize()
减少每个颜色通道的位数在每次位更改中都会看到颜色收缩的变化
用法: PIL.ImageOps.posterize(image)
参数:
image-用于后代化的图像。
bits-每个通道要保留的位数(1-8)。位8是通道可以使用的最大位。
返回:一个图像。
使用的图片:
# Importing Image and ImageOps module from PIL package
from PIL import Image, ImageOps
# creating a image1 object
im1 = Image.open(r"C:\Users\System-Pc\Desktop\a.JPG")
# applying posterize method
im2 = ImageOps.posterize(im1, 2)
im2.show()
输出:
位-这里的位4可以通过更改通道中的位来了解颜色的变化。
# Importing Image and ImageOps module from PIL package
from PIL import Image, ImageOps
# creating a image1 object
im1 = Image.open(r"C:\Users\System-Pc\Desktop\a.JPG")
# applying posterize method
im2 = ImageOps.posterize(im1, 4)
im2.show()
输出:
相关用法
- Python next()用法及代码示例
- Python os.dup()用法及代码示例
- Python set()用法及代码示例
- Python Decimal max()用法及代码示例
- Python PIL ImageOps.fit()用法及代码示例
- Python os.rmdir()用法及代码示例
- Python sympy.det()用法及代码示例
- Python Decimal min()用法及代码示例
- Python os.readlink()用法及代码示例
- Python os.writev()用法及代码示例
- Python os.readv()用法及代码示例
- Python PIL RankFilter()用法及代码示例
- Python os.rename()用法及代码示例
- Python os.sendfile()用法及代码示例
注:本文由纯净天空筛选整理自Sunitamamgai大神的英文原创作品 Python PIL | ImageOps.postarize() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。