In simple terms, what does Tone Curve in LR actually do?. I can see the results of changing Tone Curve by playing around with it, but I don't really understand scientifically what it actually does. I read a few documents on it, including one from Adobe, but I just got lost.
Expanding on Miguel's answer with an illustration, I have in the center a test image gradient with no curve adjustment. On the left I am using a steep curve that pushes my shades of grey closer to extreme black or white, spreading out values near middle grey over a larger range of shades. The effect is that the extreme dark and light areas encroach more on the middle grey portion of the gradient. The right image is being flattened by a horizontal curve. The effect is that a wide range of values are being squeezed close to middle grey leaving only small bands of extreme light and dark.
An important point to understand with digital images, and something which may make the Tone Curve tool easier to understand from a technical perspective, is that digital images are formed from a limited palette of colors (or in this case, tones). For our purposes, tones are shades of grey (in a color image tones would be more like the 'brightness' or 'darkness' of a given color hue).
In my three example images, the gradients you see are made from 256 different shades of grey ranging from white to black. What the Tone Curve tool allows me to do is shift how I want to distribute my limited range of tones. To help make this more visible, I have created a version of my images using only 11 shades of grey.
What you can now see more clearly is that in the the center image, my limited set of tones is distributed more or less evenly, providing equal amounts of detail in the light, middle, and dark areas. In the left image most of my limited set of tones is being used in what used to be the middle grey region. This has changed the look of the image (by moving both more light and more dark tones to what used to be a fairly neutral area) but this comes with the advantage of being able to represent more fine detail in that tone region. Similarly, in the right image most of the tones are now being used to describe detail in the formerly extreme dark and light areas, with loss of detail the the middle grey region.
The "Point Curve" selector at the bottom of the pallet (which is defaultly set to Linear) can be used to add additional preset adjustments on top of whatever settings you have set manually. In a sense, its two other options (Medium Contrast and Strong Contrast) redefine what the "0" values of the four sliders represent.
A tone curve is a curve that describes how to turn a shadow, mid-tone or highlight into it's final value for the image you are after. It can add more contrast, reduce contrast or selectively boost shadows, midtones and highlights. These operations can also be done on a per-channel basis (such as red, green and blue) to adjust the colour of a pixel as well.
An input value towards 0.0 (black, shadows) may be transformed to be lower than it was. So a dark pixel with a brightness of 0.1 might be turned into 0.05, making it half as bright as it was.
An input value towards 1.0 (white, highlights) may be transformed to be higher than it was. So a bright pixel in the photo with a brightness of 0.9 might be turned into 0.95, making it 5.5% brighter than it was.
In practical terms, this common S shape of a tone curve increases contrast. It makes highlights brighter and shadows darker. This has a byproduct of increasing saturation as the separation of each red, green and blue channel will be increased, tending away from gray.
In the middle, the pixels are unaffected and are gradually pushed brighter and darker as you tend towards bright and dark pixels.
A tone curve could leave the bottom half of the tones alone and only make highlights brighter, or even make them darker to bring detail back into a sky, for example. In contrast, only shadows could be made brighter, or made even darker and also be used to make blacks appear in less black regions.
Since Miguel provided an excellent mathematical answer, I'll try to provide a visual and practical analysis of the tone curve tool in Lightroom. To put it simply, it lets you adjust the luminance of the range of tones in a photograph. Lightroom enhances the basic tone curve with four adjustable tonal ranges that can be attenuated, giving you a bit more control over how adjustments to the tone curve affect the image itself.
A basic analysis of the tone curve itself is best started with a linear curve, which makes no adjustment to the tones of the image in any way...output is the same as input.
A common tone curve is a strong contrast curve, which attenuates both the shadows and the highlights to compress them, resulting in a stronger difference between the light and dark parts of the output image.
Directly editing the tone curve gives you the ability to apply some artistic finesse to a photograph. In the case of the image I took the two crops above from, I want to make the trees mostly black silhouettes, framed against the sky. The tone curve is perfect for this, as I can adjust only the darkest tones (shadows) in the image. By REDUCING the level of the shadows by pulling that part of the tone curve down, I can make the trees fully black, and therefor achieve my artistic silhouette.
The adjustment above worked, however the rock in the foreground darkened quite a bit along with the trees. That wasn't really what I wanted. Lightroom allows you to adjust what range of tones is considered "shadows", and what range of tones is considered "darks" (between shadow and normal tones) using the three sliders embedded in a black to white gradient just underneath the tone curve. By moving the left-most slider farther to the left, I limit the range of tones affected by my previous adjustment, and I can restore the tones of the rock without affecting the trees much.
The final image below has had a couple additional adjustments, to both the tonal ranges (darks have been reduced to further enhance the tonality of the foreground rocks without affecting the silhouetting of the trees, and the curve for both darks and lights a bit.
Hopefully these visual examples will help improve your understanding of the tone curves tool.
I like to think about the tone curve in terms of a function:
The input value x to the function is a pixel value from the source image, which is actually the brightness of that pixel. Let's say the values of x can range from 0.0 (black) to 1.0 (white), with all the gray tones represented as real numbers between 0 and 1 (to simplify things a bit let's assume the picture is black & white so there is only one value per pixel, I will later extend the concept to color pictures).
The output value y returned by the function is the transformed pixel value, also in the range 0 to 1.
Thinking in these terms, a tone curve transformation is done simply by calling the t() function above for every pixel in the source image and replacing that pixel with the transformed pixel returned by the function.
If you have a color image, then there are a couple of ways you can go about it. You could apply the function to the "L" component of every pixel using the HLS color model. Another option would be to apply different tone curve functions to R, G and B, then assemble a transformed RGB image with all those results. In Lightroom you only have the first kind, or in other words, a single curve for the whole image. In Photoshop or GIMP, the Curves adjustment can also be applied independently to the R, G and B channels.
A natural way to represent this t() function is with the use of a curve. Just represent the x values along the X axis and the y values along the Y axis. Then for each possible value of x you plot a point at coordinates (x, t(x)).
The simplest possible curve would be a diagonal line, going from (0,0) to (1,1). This would be when you are not applying any transformation at all, or in other words, t(x) = x.
A curve that is a horizontal line at the Y=1 height would mean that for any input the result is 1, or white. This would transform any image into full white. Conversely, a horizontal line at Y=0 would make any image fully black.
If you wanted to increase the tonal range available for the midtones in your picture, then you can do so by compressing the darks and the highlights. The shape of the curve in this case will resemble a slanted letter "S".
As a general rule, if a segment of the curve is more horizontal than vertical it means that you are compressing the range of tones covered by that segment. If the segment is closer to a vertical then the range of tones is being expanded. A segment that is a perfect diagonal means that there is no expansion or compression, just a linear mapping from one set of values to another.
One additional comment. While you can edit the Lightroom Tone Curve directly by dragging the curve, the tool has these four sliders below the curve that I think are pretty cool. Instead of messing with the curve directly, the sliders are pre-programmed to affect four different sections of the curve independently. By default each slider affects a 25% of the tonal range space. The little buttons over the X axis of the curve can be dragged left and right to change how these four regions are defined. I find I get better results when I modify the curve via the sliders, for me it is easier to think about the adjustment I want to make in terms of just four areas.
Edit: Regarding compression and expansion, consider that in a picture there are a finite number of brightness values that can be represented, so you have to distribute these tones in the way that benefits your picture the most. For example, if your picture came up too dark, that means that a lot of the pixel values are going to be on the low end of the brightness scale, and the brighter part of the scale will be a lot less used or not used at all. With the Tone Curve you can expand those dark tones to cover a larger part of the brightness scale, and that can make stuff that was barely visible in the original much more clear to see. Since the brightness scale is finite, if you expand in one part you must compress in another, the curve just allows you to do localized adjustments in different parts of the scale, so you can sacrifice (compress) in one part so that you can provide more tonal detail in another.