码迷,mamicode.com
首页 > 编程语言 > 详细

调用系统的语言功能及图片的处理

时间:2019-10-20 17:57:21      阅读:78      评论:0      收藏:0      [点我收藏+]

标签:convert   vbs   调用   range   span   new   col   sap   creat   

from PIL import Image
img = Image.open(11.jpg)
img_mode = img.mode
print(img_mode)
dr = img.size
print(dr)
xs = img.getpixel((0,0))
print(xs)
‘‘‘
RGB
(500, 500)
(122, 114, 93)
‘‘‘

new = Image.new(L,img.size,255)



width,height = img.size


img = img.convert(L)



pen_size = 3


Color_Diff = 6


for i in range(pen_size+1,width-pen_size -1):
    for j in range(pen_size+1,height-pen_size-1):
        originalcolor = 255
        lcolor = sum([img.getpixel((i-r,j))for r in range(pen_size)])//pen_size
        rcolor = sum([img.getpixel((i+r,j))for r in range(pen_size)])//pen_size
        if abs(lcolor-rcolor)>Color_Diff:
            originalcolor -= (255 - img.getpixel((i,j)))//2
            new.putpixel((i,j),originalcolor)
        qcolor = sum([img.getpixel((i, j - r)) for r in range(pen_size)]) // pen_size
        wcolor = sum([img.getpixel((i , j+r)) for r in range(pen_size)]) // pen_size
        if abs(qcolor - wcolor) > Color_Diff:
            originalcolor -= (255 - img.getpixel((i, j))) // 2
            new.putpixel((i, j), originalcolor)

new.save(img_tony.jpg)

os.system(mshta vbscript:createobject("sapi.spvoice").speak("%s")(window.close)%您的人物绘画已经完成)

os.system("img_tony.jpg")

 

调用系统的语言功能及图片的处理

标签:convert   vbs   调用   range   span   new   col   sap   creat   

原文地址:https://www.cnblogs.com/HUIWANG/p/11708052.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!