If you want to get a gradient map effect. The procedure is as follows:
Luma = 0.2126 * R + 0.7152 * G + 0.0722 * B
- Once you have your brightness, you must create a function to display the brightness from 0 ~ 100% to the color gradient you want from 0% to 100% ... In other words:
luma = 0% → color A
luma = 100% → color B
luma = X% → interpolation between A and B ... InterpolatedColor = X% * B + (100 - X)% * A
Of course, apply this formula for all channels R, G, and B.
This can be done easily in PHP as soon as you get access to the image pixels.
source share