from PIL import Image img = Image.open("scratch/tmp/frame_last.jpg") img = img.convert("RGB") w, h = img.size green_count = 0 for x in range(w): for y in range(h): r, g, b = img.getpixel((x, y)) if g > 200 and r < 50 and b < 50: green_count += 1 print(f"Green ratio: {green_count / (w*h):.2f}")