I'm trying to find the brightness of pixels along a horizontal line across an image but I'm stuck on how to get either an array of numbers or maybe using a loop to change the x values and output the values of the pixels so I can calculate the brightness of each and then I can average across that line. This is what I got so far:
from PIL import Image
from math import sqrt
import os
image = Image.open(os.path.join("mypath", "a.jpg"))
import numpy as np
image = imag.convert ('RGB')
X,Y = (137, 137) #this is where i dont know what else to add
pixelRGB = imag.getpixel((X,Y))
R,G,B = pixelRGB
brightness =([R,G,B])/3
print(brightness)
I don't know how to add a loop.


You should iterate from 0 to
widthwith a loop: