首页 > 其他 > 详细

修改图片的RGB

时间:2020-08-29 22:34:04      阅读:96      评论:0      收藏:0      [点我收藏+]
#from PIL import Image
#
#im = Image.open("1.png")
#
#for y in range(im.size[1]):
#    for x in range(im.size[0]):
#        pix = im.getpixel((x,y))
#        print(pix)


#from PIL import Image
#im = Image.open("1.png")
#count = 0
#for y in range(im.size[1]):
#    for x in range(im.size[0]):
#        pix = im.getpixel((x,y))
#        if(pix[0] < 100 and pix[1] < 100 and pix[2] < 100):
#            count = count + 1
#print(count)


#from PIL import Image
#im = Image.open("1.png")
#im2 = Image.new("RGB",im.size,255)
#count = 0
#for y in range(im.size[1]):
#    for x in range(im.size[0]):
#        pix = im.getpixel((x,y))
#        if(pix[0] < 100 and pix[1] < 100 and pix[2] < 100):
#            im2.putpixel((x,y),(255,255,255))
#im2.show()



from PIL import Image
im = Image.open("3.png")
count = 0
for y in range(im.size[1]):
    for x in range(im.size[0]):
        pix = im.getpixel((x,y))
        if(pix[0] < 50 and pix[1] < 50 and pix[2] < 50):
            im.putpixel((x,y),(255,255,255))
        
im.show()

 

修改图片的RGB

原文:https://www.cnblogs.com/3-wusen/p/13583628.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!