I am creating an application for iPad which can change the images by detecting the brightness of the room. So I want to know is there a way to detect the brightness of the room ?
One approach is to take the average brightness of some set of pixels in your image. If you have an image with RGB pixels, you can get the brightness by adding the weighted components. A common weighting is 30% red, 59% green, 11% blue:
brightness = pixel.red * 0.3 + pixel.green * 0.59 + pixel.blue * 0.11;
Depending on the variations in your image, how accurate a measure you need, the resolution of your image, etc. you can average a sample of pixels from around the image, or just average all of them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With