3

I want to adjust exposure of an image using Java. I know in Java 2D there are existing functions doing this job. But I also want to know how it works on color level. I did some research online and it says we can multiply R,G,B with certain parameters to achieve overexposure, what are the parameters? and how about underexposure? Thanks in advance!

Tony
  • 253
  • 1
  • 4
  • 12

1 Answers1

2

You might find this page useful, has some quite detailed information on generic exposure functions:

In general however, exposure adjustment is all about shifting the colour curves using some form of smooth monotonic function what maps the range 0..1 to the same 0..1 range:

  • It needs to be monotonic (always increasing) so that lighter areas stay lighter than darker areas after the transformation
  • It needs to be smooth so that you don't create sudden jumps / banding in colour gradients
  • It needs to act on the range 0..1 since that is where your (normalised) RGB colour values are!

A simple example of such a function would be:

new component value = (old component value) ^ k

Here a parameter value of k>1 would darken the image, k<1 would lighten the image. You can play with the parameter and the formula until you get an effect you like.

mikera
  • 105,238
  • 25
  • 256
  • 415
  • Thanks ! I tried your method and it works! it's much easier for me to control the single k rather than adjusting parameters for R,G,B respectively! I will go through the resource you recommend although it seems a bit complex at the first glance. And another question, what do you mean by "using some form of smooth monotonic funcion"? From what I understand so far from your answer, we only need to change the exponential value on old component value to adjust exposure, so how come there are "some form"? Please enlighten me! – Tony May 17 '12 at 01:27
  • There are many different possible "smooth monotonic functions" that fit the criteria. I just gave you an extremely simple / convenient one with a single parameter. Some functions are probably more physically realistic in terms of modelling the effect of light on camera sensors, some may give you a greater range of artistic effects (e.g. greater control over light/dark regions). Ultimately though, it's up to you to choose whatever works for the effect you are trying to achieve! – mikera May 17 '12 at 01:33
  • Fair enough. Thanks again! It does solve my problem. I may go check other functions if I need to. – Tony May 17 '12 at 01:43
  • See also this [example](http://stackoverflow.com/a/10208380/230513) illustrating `RescaleOp`. – trashgod May 17 '12 at 02:17