How can I change backlight intensity with root on lcd phone? I want to have the backlight on my phone dynamically change intensity, even turning completely off during completely black screens and such. How possible is this? It's a nexus 5 running cataclysm 5.0.1 with elementalx kernel.
You could consider capturing an image of the screen, then processing that bitmap for the brightness of each pixel.

The Android Screenshot Library (ASL) should give you information on how to do a screen capture. This link on StackOverflow talks about how to do it as well, but the main link seems to be to the ASL.

To calculate the luminosity of the pixels, you could do it in either of the RGB or HSV color spaces. I think I'd do it in HSV, since the Value (the V in HSV) is the brightness of the pixel's color. You could also do it with the three color parameters in the RGB color space, but then you're working with ratios and you're having to perform more calculations yourself. With HSV you would (I think) simply add up all the Values and divide by the number of pixels. (Possibly you'd throw in a scalar if a linear change in brightness doesn't look quite right. Eg: Have a slower backlight change when you have bright graphics, but move more quickly towards no backlight when you have graphics approaching black.)

With that working, you might want to consider doing the work using Android's RenderScript. Processing graphics is what RenderScript was designed for, and it takes care of parallelism for you. You might as well use all the CPU / CPU / DSP cores you have available.

Finally, you might want to follow this up by getting tricky and using the device's light sensor information. After all, if you're going to dynamically change the backlight based on what is on the screen, you might as well also consider the ambient brightness around the device. :-)

I hope that helps!

Edit: I hope you were looking for a programming answer. I hadn't really thought about the fact that this question was posted to Android Enthusiasts instead of to Stack Overflow. :-)