skip to Main Content

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


  1. 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:

    originalImage = getImage();
    brightnessImage = applyBrightness(originalImage);
    contrastedImage = applyContrast(brightnessImage);
    

    and so on. Everytime something changes.

    I think this is reasonable, since you don’t seem to deal with very expensive operations.

    Login or Signup to reply.
  2. 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 :

    brightnessDelta = brightnessSlider->value() - latestBrightnessSlider;
    constrastDelta = contrastSlider->value() - latestContrastSlider;
    
    latestTransformedImage = getImage();
    applyBrightness(latestTransformedImage, brightnessDelta);
    applyContrast(latestTransformedImage, contrastDelta);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search