Pages: 1 [2]   Go Down

Author Topic: TUTORIAL: White balancing JPEG in Photoshop  (Read 10174 times)

madmanchan

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2115
    • Web
TUTORIAL: White balancing JPEG in Photoshop
« Reply #20 on: July 20, 2008, 01:25:44 pm »

The commutativity demonstrated above is true as long as the curve is a pure gamma curve (i.e., f(x) = x^g for some constant g, such as 1/2.2 in the case of a gamma 2.2 encoding curve).

The issue occurs if one is dealing with an already-rendered image where an arbitrary tone curve has been applied to the linear raw data, separate from the gamma encoding. All raw converters do this, and the curve is rarely (if ever) a straight 2.2 curve, for the reasons Bill has demonstrated above ... namely that without a separate curves tweak, the result doesn't look good.
Logged
Eric Chan

Peter_DL

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 544
TUTORIAL: White balancing JPEG in Photoshop
« Reply #21 on: July 21, 2008, 12:40:21 pm »

Quote
To explore the commutative nature of linear scaling and gamma encoding, I did an experiment with Iris, an excellent freeware program popular with astronomers and experimenters.

... The normal processing flow is to do white balance first, then apply the gamma, and finally one may want to use a curve to improve contrast and set the black and white points. Here is the raw image after white balancing; Iris used the following RGB multipliers: 1.878, 1.0, 1.310.

… If one applies a gamma of 2.2 and then performs white balance, the multipliers are 1.33, 1.0, and 1.127. The results are the same of one uses the reverse order, confirming the commutative nature of the operations.
[{POST_SNAPBACK}][/a]
Hi Bill,

This commutative relation between Linear scaling and Gamma is a very interesting aspect as I find. Thanks for the testing. As we know, it can be disturbed – measurably and visibly: a.) by a non-regular gamma such as with sRGB, and b.) application of an S-curve in-between, such as used to render from 'native' Raw to a pleasing tonality.

Both limitations a.) and b.) can be seen as given with an already processed image file.  For ex-post correction of white balance, it is certainly not wrong to change to a linear space. Anyway, it can easily be that any one-point procedure via linear scaling of the highlights is not enough.

There’s probably good reason why such belated white-balance was always considered to include a mid tone adjust [see point #2 [a href=\"http://www.creativepro.com/article/out-of-gamut-five-cheap-tricks-in-photoshop-6]here[/url], or this one (sorry, the new layout of these classics looks odd)].

My 2ct. Thanks again for weighting in.
Peter

--
« Last Edit: July 21, 2008, 12:41:10 pm by DPL »
Logged

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
TUTORIAL: White balancing JPEG in Photoshop
« Reply #22 on: July 21, 2008, 01:56:44 pm »

Quote
I found your comments valuable, since I had previously thought that white balance could not easily be performed with a gamma 2.2 image because of the non-linearity thus introduced.
True. Since Peter showed such a simple math relation I am doing some considerations that make linear edition less attractive to me or at least less necessary for certain image adjustments.
For instance to correct exposure by N f-stops over a gamma encoded image is just as simple as dividing N by gamma:

- Linear image: OUT_lin = IN_lin * (2^N)
- Gamma image: OUT_gamma = IN_gamma * (2^N)^(1/g) = IN_gamma * 2^(N/g)

Both are as simple and fast to compute.


Recalling the WB adjustment, for those who feel more comfortable with Levels than with Curves in Photoshop the procedure would be the same:
- Set a Levels layer picking a neutral point of the image as white point
- Set a second Levels layer in-between the image and the previous Levels layer to reduce exposure through the output levels adjustment.

The sample image and both Curves and Levels layers can be downloaded from:
WB with Curves
WB with Levels

The combination of the 2 layers in Adobe RGB (gamma 2.2) is equivalent to these curves:

« Last Edit: July 22, 2008, 03:22:06 am by GLuijk »
Logged

bjanes

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 3387
TUTORIAL: White balancing JPEG in Photoshop
« Reply #23 on: July 21, 2008, 10:37:38 pm »

Quote
Hi Bill,

This commutative relation between Linear scaling and Gamma is a very interesting aspect as I find. Thanks for the testing. As we know, it can be disturbed – measurably and visibly: a.) by a non-regular gamma such as with sRGB, and b.) application of an S-curve in-between, such as used to render from 'native' Raw to a pleasing tonality.

Both limitations a.) and b.) can be seen as given with an already processed image file.  For ex-post correction of white balance, it is certainly not wrong to change to a linear space. Anyway, it can easily be that any one-point procedure via linear scaling of the highlights is not enough.

[a href=\"index.php?act=findpost&pid=209740\"][{POST_SNAPBACK}][/a]

Peter,

To evaluate the extent of the effect of tone curves beyond a straight gamma 2.2 encoding, I looked at some old work I did with Stouffer stepwedges and Imatest with the Nikon D200. The linear raw file as converted by DCRaw is shown; it is linear except for the shadows where I think there is some flare light.

The Nikon Capture defaults are those with normal contrast set in the camera and are very similar to in camera JPEGs. The ACR with default settings applies an S-curve and rolls off the shadows rather markedly, somewhat greater than Nikon Capture. The default ACR curve with black set to 0 shows the S curve to better advantage. ACR with linear settings (brightness = 0, contrast = 0, black = 0, tone curve = linear) is also shown. It is linear, but the gamma is about 1/2.01.

The conversions were sRGB in Photoshop except for the Nikon Capture conversion. I don't know if these programs use a linear curve for the shadows or not. I remember vaguely that Photoshop may use a simplified curve without a linear segment.

For white balancing, it might be possible to apply a curve to undo the above renderings, but obviously clipped data can not be restored. Otherwise, the white balance would not be optimal--I would image that it would vary between shadows and highlights. Overall, Guillermo's method shows a marked improvement, but he now recognizes that it is not essential to convert to a gamma 1.0 rendering.    

[attachment=7581:attachment]

Bill
Logged

Mark D Segal

  • Contributor
  • Sr. Member
  • *
  • Offline Offline
  • Posts: 12512
    • http://www.markdsegal.com
TUTORIAL: White balancing JPEG in Photoshop
« Reply #24 on: July 22, 2008, 09:59:46 am »

Quote
The commutativity demonstrated above is true as long as the curve is a pure gamma curve (i.e., f(x) = x^g for some constant g, such as 1/2.2 in the case of a gamma 2.2 encoding curve).

The issue occurs if one is dealing with an already-rendered image where an arbitrary tone curve has been applied to the linear raw data, separate from the gamma encoding. All raw converters do this, and the curve is rarely (if ever) a straight 2.2 curve, for the reasons Bill has demonstrated above ... namely that without a separate curves tweak, the result doesn't look good.
[a href=\"index.php?act=findpost&pid=209580\"][{POST_SNAPBACK}][/a]

Eric, I think this is the nub of the issue that has sparked a copnserable amount of discussion in the past about two things (1) the relative merits of setting white point in Camera Raw, versus doing so to a rendered image in Photoshop, and (2) the question about whether an application such as Camera Raw should give the photographer the option of rendering the image without an arbitrary tone curve - eventhough the results may look crummy - so as to avoid the accompanying saturation boost, and letting the photographer dial-in whatever more saturation he/she may want thereafter in Photoshop.

Re (2) I have argued in the past that it is a non-issue (mainly because there are ample controls in Camera Raw for handling such issues non-destructively), and re (1) I and others have found empirically that Camera Raw's white balance function is easier and more accurate across the board than doing it curve-by-curve in Photoshop to a rendered image. The sense I'm getting from this discussion - though I am not an imaging mathematician - is that there is a theoretical basis for these observations. Care to comment?
Logged
Mark D Segal (formerly MarkDS)
Author: "Scanning Workflows with SilverFast 8....."

Mark D Segal

  • Contributor
  • Sr. Member
  • *
  • Offline Offline
  • Posts: 12512
    • http://www.markdsegal.com
TUTORIAL: White balancing JPEG in Photoshop
« Reply #25 on: July 22, 2008, 10:41:30 am »

Eric, as a follow-up, is it safe to say that if one opened a TIFF or a JPEG in Camera Raw, one could set the white balance there in the Basic Tab as reliably as one could using the technique Guillermo demonstrated?
Logged
Mark D Segal (formerly MarkDS)
Author: "Scanning Workflows with SilverFast 8....."
Pages: 1 [2]   Go Up