I currently have a code for measuring the average brightness of an RGB image. When i run this with a black and white image, the RGB values are the same, e.g. 37, 37, 37 I have no idea about colours etc but i dont think this is correct
Here is my code at the moment:
from PIL import Image
from math import sqrt
imag = Image.open("../Images/pexels-photo-57905.jpeg")
imag = imag.convert ('RGB')
imag.show()
X,Y = 0,0
pixelRGB = imag.getpixel((X,Y))
R,G,B = pixelRGB
brightness = sum([R,G,B])/3 ##0 is dark (black) and 255 is bright (white)
print(brightness)
print(R,G,B)
In a nutshell, i must convert an RGB image into grayscale, which im using .convert('LA') for, i must THEN measure the brightness of the image by adding the black and white values then dividing them by 2