# Why can I adjust the white balance of a RAW file but not a JPEG file?

I recently started setting my DSLR to save RAW files, and using Adobe Lightroom to process them. I still, however, use my little point and shoot camera a lot which does not have an option to save RAW files. I've also noticed that in light-room the white balanced options are different with RAW files vs JPEG files. With RAW files you have the option of choosing from a number of white balanced settings (florescent, halogen, auto etc..), whereas with JPEG you do not. Why is this?

• Dec 25, 2011 at 16:11

All images start as RAW files that must have colour balance applied to them.

For jpeg images this transformation is done in the camera using the camera white balance settings. As mentioned above, Lightroom does not have enough information to undo this transformation.

Saved RAW files have no transformations applied by the camera, allowing you, the photographer, to decide later which white balance transformation you wish to apply.

Let's consider the image captured by the sensor (RAW) as calibrated and neutral.

The equation is the following to generate a color balanced JPEG is:

JPEG = RAW * T


where T is the color balance transformation

Normally to apply a different color balance to a JPEG, you would need to apply the inverse of as-shot transformation to the JPEG (to restore the neutral image)

NEUTRAL = JPEG * 1/T


then apply the new color transformation

NEW_JPEG = NEUTRAL * T2


Unfortunatly, the JPEG image (at least those generated by my Nikon D50) does not include the temperature setting of the image as-shot. So it means the T of the equation is unknown by Lightroom when you only have the JPEG image. So it can't apply the inverse transformation to restore a neutral image.

Instead it uses different generic transformations to transform the color balance.

• Never thought to see an answer here using mathematics, but it's just like that! Dec 5, 2010 at 15:59
• We like math here. :) Dec 5, 2010 at 16:07

Great technical answers so far. Here's a simple analogy that may not be exactly right but anyway:

A RAW file is like an film negative. You can work with it in a darkroom (Lightroom) and print it (JPG). A JPG is like a print. Once printed, there isn't much you can do.

• Simple and concise! Dec 5, 2010 at 15:58
• Except that a film has a specif profile regarding its sensitivity to the various wavelengths of light already baked in. No matter how much you do in the darkroom, you can't change that profile. In a sense, color film is already demosaiced before it is exposed. What you manipulate in the darkroom in terms of WB is actually much more like what is done to a jpeg than what is done to a RAW file: The relative levels of R, G, and B. Apr 27, 2013 at 13:43

Decastlejau's answer provides some great technical insight for those like myself who love all things technical. For the timid of hart when it comes to mathematics, here is a less complicated answer. With RAW, you have original sensor data, which is generally stored as original red, green, or blue SENSOR readings for each pixel of a digital sensor, as well as other metadata such as exposure details, camera state (i.e. white balance), camera settings, and possibly a variety of additional data.

A raw image is essentially a direct dump of data from a digital sensor, which are usually red, green, and blue light-sensitive pixels (photosites) arranged in a bayer color filter array. As RAW is original sensor data, you have the maximum amount of information available to you, which usually includes considerably greater bit depth (and dynamic range) than an image saved into another format. This is the "neutral" image that decastlejau mentioned...no adjustments or tone curves have been applied, it is truly original data.

The pixels of a RAW image do not directly map to the pixels on a screen, and as such, they can not be viewed directly. To view a RAW image, this raw sensor pixel data must be passed through a rendering algorithm that takes the raw sensor data, and applies various adjustments and attenuations, such as a tone curve, white balance adjustments, exposure adjustments, etc. to generate screen pixels that each contain red, green, and blue elements. This algorithm must be applied any time any adjustment is made to a RAW image in order to view the final image on a screen. By working with RAW in this way, you maintain the original sensor data in a pristine state, allowing you to radically alter any of the adjustments in this "processing pipeline" at any time, and see ideal results in the image rendered to the screen. Most algorithmic processing of RAW data results in a LOSS of information in the final image to one degree or another. Applying a tone curve, for example, usually results in improved contrast, but a loss in dynamic range.

A JPEG image, in contrast to a RAW image, is one that has already been processed by an algorithm that applies a tone curve, white balance settings, etc. to create a final image. Since a JPEG is already processed, the original sensor data is lost. The same would apply if your camera saved out a TIFF file instead of a JPEG...processing original sensor data "freezes" it into a final state. Processed images are not completely devoid of headroom, and adjustments can still be made. The higher the bit depth and wider the gamut you save to, the more headroom you will have, however you will never have quite the same amount of flexibility as you would if you were using RAW.

One example of the limited headroom is in the area of white balance adjustments. Each pixel in a JPEG now contains red, green, and blue color information. This limits the amount of white balance correction you can achieve without encountering odd color casts or color splitting, especially with larger adjustments. It is possible to take such adjustments farther with RAW since you can re-blend each pixel in the final image from original red, green, and blue sensor data, allowing you to eliminate color casts.

Actually you can adjust white balance from a jpg image. Only the results will be far inferior of the ones you can get from a RAW file. As discussed much better on other answers, jpg files contains much less data than RAW ones, so there is no such margin to change color balance. The same is true for exposition and contrast settings.

Said that, is it possible anyway to slightly change the white balance of jpg images using other programs, but in Lightroom they decided that the poor results you can manage from jpg files won't be good enough for tipical Lightroom user.

Note also that this is nothing to do with jpg compression techniques, only that jpg file format store less information.

• It's not just that there's less information, but that the particular information which is lost is crucial to this adjustment. To adjust wb in a JPEG, you need to have some idea of the adjustment already applied to it (or else guess, or have the computer guess). Dec 5, 2010 at 15:45
• Not really, from the algorithm point of view it's only a matter to weight differently the 3 channels RGB. Also from a practical point of view you need only to find a real white (or neutral gray) pixel in the picture to wb. Dec 5, 2010 at 20:12

Perhaps this analogy will help clarify the reason why RAW white balancing is superior to JPEG white balancing.

Imagine that you have a black and white picture. It's pretty clear that there is no automated way to put color back in that picture. Since there are many different shades of color that map to a given shade of gray, there's no way to tell what the original colors were. You can guess (as was done with colorizing old movies), but you can never be sure.

Now imagine a picture whose white balance was so screwed up that everything is a shade of blue. This situation is similar to that of the black and white picture. You've lost information about the reds and the greens that were originally in the picture. A computer program that removes the blue tint so that there is no overall tint will not give you the original picture back, but rather a black and white shot.

Of course, most white balances are not as messed up as in the examples above, and JPEG white balancing works okay. But, you will always get a more accurate conversion when you have the original information from the shot, as in RAW.

decasteljau's answer is excellent on the technical workings. Let me add some fluff, though:

A RAW file has linear data from the sensor — more photons strike each photosite equals a directly higher reading. And that's split evenly into red, green, and blue. (Well, technically, twice as many green receptors in most sensors. But that's an implementation detail.)

This isn't how the human vision system -- the eye and the brain -- perceives things at all, though.

First, we perceive brightness in a non-linear fashion, which is why we are able to deal with bright sun and dark shadows all in the same scene without it looking weird. This is why curves are applied to a RAW image in order to make an appealing final output image. You could skip this and generate a linear JPEG, but it would look flat (no pun intended) and strange.

Second, we perceive color based on an inherent sense of what things should be colored, which is why they look normal to us under both cool and warm lights, and even, after a bit of adjustment, under very oddly tinged light. If the light is "really" strongly blue, we tend to not see it — but if you take a photograph, more blue photos will be recorded. An image file knows nothing of how things "ought" to look, and needs to have a white balance correction applied to make the image match our mental expectations.

When converting from a RAW file, the converter is working from a known starting point. It either has a detailed profile for your camera model (or even one you've generated yourself), or at least a basic color matrix matching that camera's general output. So, it can go from that state to apply various adjustments — this is the "RAW * T" in decasteljau's answer, and if you change your mind, since usually the original RAW file is left unmodified, it can start again from that baseline and apply a different transform.

Once you have a JPEG file, that baseline is lost, and there's no known from to start adjustments with.

Tone Curves and Saturation make this difficult because:

(1) they happen after white balance

(2) they are non-linear, which means the order of operations matters

(3) they depend on camera model and Picture Control settings

1 & 2 mean this processing must be backed out before white balance can be adjusted. 3 means it is impossible to back out precisely.

There exists a transformation which can fix white balance without backing out these other steps, but that transformation is non-linear and different for every camera. A patient user can find it manually using a Curves control. To do it automatically would require camera-specific reverse engineering.

• I think you got the best answer. Aug 22, 2018 at 19:33