Getting list of pixel values from PIL

前端 未结 9 1185
感动是毒
感动是毒 2020-11-27 15:07

Guys, I\'m looking for a bit of assistance. I\'m a newbie programmer and one of the problems I\'m having at the minute is trying to convert a black & white .jpg

9条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 16:01

    Or if you want to count white or black pixels

    This is also a solution:

    from PIL import Image
    import operator
    
    img = Image.open("your_file.png").convert('1')
    black, white = img.getcolors()
    
    print black[0]
    print white[0]
    

提交回复
热议问题