'How to get the value of r, g, b seperately using PIL

I am trying to get the separate value of red for a pixel, the value of green for a pixel, and the value of blue for a pixel. for now, I get all three of them as a tuple. is there any way I can do this in PIL for python.

I've tried splitting the image using this

r, g, b = im.split() print(r) but it gives me <PIL.Image.Image image mode=L size=225x225 at 0x10E4DB0D0> and I'm not sure what that is but the hexadecimal value seems to be the red value but my main purpose is to blend two images together by adding their separate r, g, b values in order to create a new image.

it seems like tuples cannot be added together as their addition is not of the values at a particular index but rather it just makes the value longer.

for example print(pixels[3, 3] + pixels2[3, 3]) gives me (255, 255, 255, 255, 255, 255). (here pixels represent the image loaded.) but I want to add the values together like 255+255 = 510 and then divide the value by two so that it can be in the range of rgb, but I can not add the values of the reds, greens and blues.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source