I am working on an app where i want to change several properties of an image like brightness, contrast, saturation, hue etc using sliders (the use case is similar to the lightroom workflow where user can change these properties just by moving sliders).
Problem:
My problem is, these properties are not commutative.
Example
Approaches i have tried:
I have tried two different approaches but both of them have failed.
Lightroom and many other image processing softwares achieve this but i don't know how, they perfectly negate the changes as user move the slider irrespective of the order in which properties are applied. I don't know how they do it and hence need help.
Note: Lately i was wondering if this can be achieved by blending(don't know which type of blend) the result of each effect applied on original image, rather than applying them on the results of previous one.
The way this works is to create a graph of the operations you want to perform on the image and re-execute the entire graph whenever any parameter changes. So if you want Brightness followed by Contrast, you'd create a Brightness node and a Contrast node, then hook them together like this:
Image -> Brightness -> Contrast -> Output Image
When the user changes either the brightness or contrast slider, you execute the entire graph with the new parameters. If you've written your image processing nodes sensibly, then this shouldn't be too slow for something like just a brightness and contrast adjustment.
If your graph is very large and complicated, it may make sense to cache some of the intermediate images and only recalculate the parts after the intermediate. But honestly, for the type of stuff shown in your picture, that shouldn't be necessary.