I’m running a project that will do more or less the same as CameraRaw/Photoshop does. The thing is, how do I handle multiple mods on the image matrix?
let me explain, I read the image Using OpenCV function, and I built a simple Ui in QtCreator, with a few sliders for contrast, exposure etc..
so I got my sliders that, on triggered action, call the function contrast(); on where I pass my Image, and the sliders value (sliders can go from -100 to 100).
Here’s the problem: if I set the exposure to +50, then my Image will increase it to +50. From that, if I try to decrease it, to +30, then the exposure will be +50 +30, as I wrote on my pixels image.
So, in order to decrease from +50 to +30, I made a copy of my image, that will be modified , and when I recall the exposure(), then the filter will be applied on the original Image.
So far so good, but, what if I’ll apply contrast() and exposure() at the same time? As I done for now, calling one of the twos will exclude the firstly called.
Is there anybody that can help with figure out a way for handling that?
2
Answers
What about applying all the transformations on the original image all the time?
You know the positions of your sliders, and you know when something changes. Then, you simply start from scratch. Take the new image and apply the transformations one by one.
In order to do this, you make the functions return a copy of the original image with the transformations applied. So, the algorithm would be something like:
and so on. Everytime something changes.
I think this is reasonable, since you don’t seem to deal with very expensive operations.
Paul92’s answers already answers your question and is probably the easiest and cleanest solution to your problem.
If you really wish/need to keep the latest transformed image instead of the original one, you can store the value of the sliders position at the latest transformation and use a delta to do the actual transformation :