Access/Edit pixel values of a jpeg image in python
Question: I'm involved in a image processing project and I use python. I'm new to
python, so please bear my lack of knowledge. I want to read a `jpeg` image,
split it into `r,g,b`. Then I have to change add a value to each pixel `r,g,b`
separately. Finally, I have to merge three of them to create a new image and
save it.

    
    
    from PIL import Image
    im = Image.open("/home/pi/desktop/codes/lena.jpg")
    im.show()
    
    r,g,b =im.split()
    

Are `r,g,b` matrices containing pixel values? Can I change the values of the
pixels directly? And can some one please tell me how to access each pixel?


Answer: First you
[split](https://pillow.readthedocs.org/reference/Image.html#PIL.Image.Image.split)
the image into individual bands.

Then maniplulate each pixels as you want using
[point](https://pillow.readthedocs.org/reference/Image.html#PIL.Image.Image.point).

Then merge three bands using
[merge](https://pillow.readthedocs.org/reference/Image.html#PIL.Image.merge).

The `split` method returns a tuple

> **Image.split()**  
>  Split this image into individual bands. This method returns a tuple of
> individual image bands from an image. For example, splitting an “RGB” image
> creates three new images each containing a copy of one of the original bands
> (red, green, blue).

