# Saturation is Broken.

Don't worry though, math can save us.

Have you ever tried to increase the saturation in your photos, excited to see the increase in vibrant colors and beauty, only to look at your skin and realize you look like a Cheeto?

The problem rests in the fact that current saturation algorithms use a multiplication based approach, so if you double the saturation, (that is, every single pixel in the image doubles its saturation value), it would cause the very lowly saturated pixels to still be very low (e.g. 0.1 doubled is only 0.2), and very highly saturated pixels become immensely more saturated (e.g. 70 doubled is 140). Because of this, the not so colorful parts of your image stay not so colorful, while the already colorful parts of your image become unrealistically colorful.

So, we need a formula that adjusts the lowly colored pixels much more strongly than it adjusts the highly colored pixels. We built a smart algorithm for adjusting saturation that I preview below:

Now, there are many asymptote equations to accomplish the task of increasing lowly saturated pixels more strongly than the already highly saturated pixels, so whatâ€™s the most natural way to do so? We know from physics that lighting deltas with roots/exponents, so thatâ€™s a good place to start. Ironically, thatâ€™s as far as we need to go. Current Saturation Filters adjust a pixelâ€™s saturation (s) with a formula f(s) which simply multiplies, that is, to double (x2) your saturation, the formula is simply f(s)=2s, for a formula that raises lower saturation values much more strongly than it raises higher saturation values, and follows natural laws of lighting, we can simply use f(s)=s^(1/p). [In this case p=2 since we are doubling saturation]. Iâ€™ve graphed the two equations below so you can see the difference, low-s values (x-axis, saturation values) shoot up much higher much faster, and high saturation values (further down the x-axis) barely increase.

# Brightness Filters can use it too!

Brightness suffers from similar issues, stemming back to the days of early computing when pixel adjustments had to be fast and we didnâ€™t have the processing power we have today to easily calculate roots on the fly for millions of pixels at a time. We can actually apply the exact same equation but to a pixels brightness value instead of its saturation value and we see much more realistic brightness adjustments (increasing or decreasing). Below Iâ€™ve included examples of original images, their adjustments using the new smart algorithm, and their adjustments using industry standard algorithms.

# Great, but how can I use this?

Youâ€™re probably interested in all of this if youâ€™ve read this far, but unless youâ€™re a computer programmer youâ€™re probably feeling a little confused about how you can actually do anything with this new-found knowledge. Lucky for you, Iâ€™ve coded an app that allows you to apply this smart-algorithm to your photos, 100% free, no watermarks or anything, just enjoy it and enjoy life and tell your friends! (And follow me on Instagram @albert).

To download the app, you can simply tap on the image below to find it on the Apple AppStore
(Android Users I am sorry, if I have time and if the community is really digging this tool, I will try and code an Android version for you or have one of my programmers do it when they are free!)

Thanks for learning with me,
-Albert

# Technical / Legal Notes

You can skip this part if youâ€™re not a coder or business...

Depending on the processor, a faster algorithm to f(s,p)=s^(1/p) could be f(s,p)=EXP((1/p)*ln(s)). I work in Objective-C so I donâ€™t need this.
Additionally, processing these functions is slow for millions of pixels but there are only so many saturation (or brightness) values from 0.00-1.00 that you can actually just pre-calculate all of the results for any values p that you will allow your users to use, and use look-up tables to speed up this filterâ€™s processing speed to even faster than current saturation adjustment algorithms.
Note: In my demo app, I perform all of these alogrihtms on CPU; you could use shaders and switch to GPU and speed would be near-instant, so optimizations likely won't be a real issue.

Both of these algorithms, and any of their refactored forms, for use in saturation and/or brightness adjustment of images are pending filing of patent via Apps4Life, LLC.