python创建缩略图和选择轮廓效果
# -*- encoding:utf-8 -*- ''' 改变颜色 --- 颜色反转''' from PIL import Image nest = Image.open("D:\\tk.jpg") r,g,b = nest.split() #获取原图的RGB通道的颜色值 newb = b.point(lambda i:i*1.1) #将B通道的颜色值增强 nest1 = Image.merge(nest.mode,(b,g,r)) nest1.thumbnail((400,254)) #创建缩略图 nest1.save("D:\\nest_2.jpg")
选择轮廓效果
# -*- encoding:utf-8 -*- ''' 轮廓效果 --- 素描 ''' from PIL import Image from PIL import ImageFilter square = Image.open("D:\\tk.jpg") square1 = square.filter(ImageFilter.CONTOUR) #选择轮廓效果
边缘强化
square1=square.convert('RGB').filter(ImageFilter.EDGE_ENHANCE)
#ImageFilter.EMBOSS 浮雕
square1.save("D:\\square0.jpg")
平滑
im.convert('RGB').filter(ImageFilter.SMOOTH)
锐化
im.convert('RGB').filter(ImageFilter.SHARPEN)
锐化遮罩
im.convert('RGB').filter(ImageFilter.UnsharpMask(radius=2, percent=150, threshold=3))