Python PIL remove sections of an image based on its colour

后端 未结 2 1399
北荒
北荒 2021-01-13 04:45

I am trying to use PIL in python to remove parts of images based on the pixels RGB values. From the documentation it would seem that the function point could do what I\'m lo

2条回答
  •  既然无缘
    2021-01-13 05:07

    Something like the following would work:

    source = im.split()
    mask = source[2].point(lambda i: i < 100 and 255)
    im = Image.merge(im.mode, source)
    

    See the PIL Tutorial under the Point Operations heading for more information.

提交回复
热议问题