Python: Check image brightness
You can access the pixel data directly through the Image.pixels property. It is a list of repeated RGBA values. To access a single pixel, use this:
img = bpy.data.images[&quot;Render Result&quot;]
value = img.pixels[(y * img.width + x) * 4 + channel]

where channel is 0 for red, 1 for green, 2 for blue and 3 for transparency.
Now, image brightness is not a clearly defined thing. You can, for example, calculate the average pixel value over the whole image:
r, g, b = [sum(img.pixels[:][i::4]) / len(img.pixels) for i in range(3)]

That was &quot;average&quot; as in &quot;arithmetic mean&quot;. Another possible interpretation of image brightness is a quantile, say, the 95th:
import numpy as np
r, g, b = [np.quantile(img.pixels[:][i::4], 0.95) for i in range(3)]

The specific choice probably depends on the kind of images you are processing.