Learn Before
Concept icon
Concept

Point Operations

The point() method can be used to translate the pixel of an image. This method can be combined with paste() to selectively modify an image.

# split the image into individual bands source = im.split() R, G, B = 0, 1, 2 # select regions where red is less than 100 mask = source[R].point(lambda i: i < 100 and 255) # process the green band out = source[G].point(lambda i: i * 0.7) # paste the processed band back, but only where red was < 100 source[G].paste(out, None, mask) # build a new multiband image im = Image.merge(im.mode, source)

0

1

Concept icon
Updated 2021-07-13

Tags

Python Programming Language

Data Science

Related