1

I am working on Video Editing application for iOS powered with Metal. I'm implementing Filters and Adjustments for Videos and Images. For now I have all appropriate shaders to change Video's or Image's brightness, exposure, contrast, saturation, hue and vibrance. The part I do not understand is the right order to apply adjustments, because the final result depends on the order (and the results are very different).

For example should I apply

Brightness -> Exposure -> Contrast -> Saturation

or

Exposure -> Contrast -> Brightness -> Saturation

or any other order?

I cannot find any resource online that can clarify the right sequence of applying adjustments. If there is any sequence that is considered right, what it is, and why?

Thanks.

Max Adamyan
  • 177
  • 1
  • 12

1 Answers1

1

When making image adjustment it's important to avoid R, G, and/or B values of pixels to clip at 0 (left side) or 255 (right side). In an RGB histogram this can be seen as a high spike at 0 and/or 255.

Let's see what four adjustments you mentioned do with the histogram roughly. I describe only a positive adjustment (the negative is simply the reverse).

  • Exposure: Stretches it out to the right. Unless the histogram has an empty right side, clipping will be guaranteed.
  • Contrast: Stretches it out to the left and right, but much faster to the left. Unless the histogram has an empty left and/or right side(s), clipping will be guaranteed.
  • Brightness: Left side is pushed down and right side is pulled up. If you go too far the right side will clip.
  • Saturation: G will be more or less untouched, R and B peaks will move left or right and can be smeared out. Clipping can occur but not so severely as with the other adjustments.

Note that especially exposure and contrast adjustments have overlapping effects and that brightness does similar things as well.

Based on the above (and my experience as a photographer plus having built the image processing pipeline of the Lapse app), I'd say that to get the best results you should:

  • First do exposure adjustment, but only if the histogram has an (almost) empty far-right area. Also this adjustment should depend on the size of that empty right side.
  • Then an empty far-left area of the histogram can be filled by increasing the contrast.
  • However, if there's an empty area left and right you could skip exposure correction and try to resolve this by increasing contrast.
  • Now that the histogram is 'filled' from left to right you can make the look a bit darker or lighter by adjusting brightness.
  • Finally, you can make color adjustments like saturation.

As you can see, which adjustment you apply depends on the image. And, there are many many more adjustments that, when combined, can result on almost the same end result.

Personally I hardly use brightness when I edit images manually.

For some more background on histograms and image adjustments have a look at these fabulous articles from Cambridge in Colour:

And, there's a whole list of related ones.

meaning-matters
  • 21,929
  • 10
  • 82
  • 142
  • Thanks for the detailed answer. I finally understand what image histogram means. But the way you described the order of adjustments feels too manual, I think it will be very hard to automate it. Is there some predefined order, that will more-or-less work for most images? – Max Adamyan Aug 15 '22 at 15:06
  • 1
    @MaxAdamyan Exposure should be done first for sure. Then contrast, followed by a brightness touch up. Finally color corrections. – meaning-matters Aug 15 '22 at 15:14
  • 1
    thank you very much. I will try it tomorrow, and come back to you with results. – Max Adamyan Aug 15 '22 at 15:19
  • 1
    I implemented the adjustments pipeline in order you described, and it is working like charm, thanks))) I also implemented simple histogram for the current frame, and that helped me to compare the results with Photo Editing Apps. – Max Adamyan Aug 19 '22 at 05:58
  • @MaxAdamyan Glad it all worked out! Once you have access to the histogram in code, you could try to do some automatic exposure and contrast corrections in left and/or right side. BTW, in case you don't know the CIFilter.io iOS app, it's very handy to get to know and try out many CI filters. I also recommend the ["Core Image for Swift"](https://books.apple.com/us/book/core-image-for-swift/id1073029980) book. – meaning-matters Aug 19 '22 at 07:30