Point and enhance

Brightness via point.

point(lambda p: ...) is a per-channel lookup. Brighten by scaling.

Goal

Brighten a dark blue field and print a pixel.

from PIL import Image
im = Image.new('RGB', (40, 40), (20, 40, 80))
bright = im.point(lambda p: min(255, int(p * 2)))
print(im.getpixel((0, 0)), bright.getpixel((0, 0)))
plt.imshow(bright)
plt.axis('off')
plt.show()
from PIL import Image
print(Image.new('L', (4, 4), 10).point(lambda p: p + 50).getpixel((0, 0)))
from PIL import Image
im = Image.new('RGB', (10, 10), (100, 0, 0))
print(im.point(lambda p: 255 - p).getpixel((0, 0)))
from PIL import Image
print(Image.new('L', (2, 2), 200).point(lambda p: 0 if p < 128 else 255).getpixel((0, 0)))