9951 explained code solutions for 126 technologies


python-pillowHow to map image using point() method


from PIL import Image, ImageOps

im = Image.open('/var/www/examples/heroine.png')

im = im.point(lambda p: p > 100 and 255)
im.show()ctrl + c
PIL

import Pillow package modules

Image.open

open given image with Pillow

.point(

maps an image with a given callback

p > 100 and 255

trims colors beyond value of 100 and returns 255

.show()

displays resulting image


How to map image using point() method, python pillow

Usage example

from PIL import Image, ImageOps

im = Image.open('/var/www/examples/heroine.png')

im = im.point(lambda p: p > 100 and 255)
im.show()