Specific Updation in a multidimensional list

18 Views Asked by At

I have got the RGB value of an image using PIL module, but I don't know how to modify the third value i.e (the Blue value )B value particularly . Help me with this>>??

1

There are 1 best solutions below

0
Inventoxz On

How to edit a pixel in a PIL image

from PIL import Image
im = Image.open('hopper.jpg')
px = im.load()

new_blue_value = 255
px[4,4] = (px[4,4][0], px[4,4][1], new_blue_value)

Because each pixel value is a tuple, you have to reassign all pixel values, as opposed to modifying a single color value