Here were the steps we took to extract the average brightness of an image.
- Convert the image to HSV color space (the Value channel is an approximation for brightness)
- Sum up all the values of the pixels in the Value channel
- Divide that brightness sum by the area of the image, which is just the width times the height.