A companding function is, in general, a nonlinear transformation of luminance (Y). It is often used to redistribute luminance values in a manner that is more uniform to the eye, in preparation for quantizing to a fixed number of discrete levels (e.g. 256 levels using an unsigned, 8-bit integer). This calculator supports conversions among luminance, CIE L*, density and gamma functions.
To use the calculator, enter a source value into a location corresponding to the type of data you are converting from. Then click the button located to its immediate left. All of the other representations are immediately calculated. The internal flow of information used to achieve the conversions is shown here:

So no matter what the source type is, the others may be reached by finding paths along the arrows.
To better understand how the calculator works, let's consider a simple example. Suppose we enter a middle visual gray like this:

When the L* button is clicked, the other values are computed according to this flow diagram:

The other colors are immediately displayed:

There are two Gamma values, labeled Gamma 1 and Gamma 2. Each has its own exponent, found at the far right. Having two gamma values allows you to convert between two different gamma functions, such as might occur for coercing a native gamma 2.2 monitor to behave as though its gamma was 1.8. Futhermore, having two gamma values also allows one to be plotted against the other in the graph at the top.
When entering numbers into the fields, the value ranges are:
| Type | Minimum | Maximum |
| Y | 0.0 | 1.0 |
| L* | 0.0 | 100.0 |
| Density | 0.0 | 10.0 |
| Gamma 1 or 2 | 0.0 | 1.0 |
| Gamma Exponent | 0.1 | 10.0 |
Let's turn our attention to the graph. The calculator is supplemented with a graphical display of companding functions. This can help you visualize and understand what these functions mean, in an intuitive sense. The horizontal axis represents the Input type, which is selected using the left hand column of radio buttons. Similarly, the vertical axis represents the Output type, which is selected using the second column of radio buttons.
You can learn things from this graph. For example, selecting Y as the input and L* as the output, you get the curve that maps the uniform intensity (i.e. energy) scale to the uniform perceptual scale. From this, you can see that a middle visual gray (L* = 50) corresponds to a luminance (or reflectance) of 0.18 (or 18%):

Photographers will recognize this as the "18% gray card" that is used for determining exposure. An 18% reflector is a middle visual gray. That's where the magic number "18%" came from.
Here's another exercise. The question often arises, "What value for gamma gives a companding function that most closely represents the CIE L* function (i.e. a uniform perceptual scale)?" We can explore this question by setting the input to L* and the output to Gamma 1 (or Gamma 2). A perfect match would be a straight line drawn on the diagonal. You can see that a gamma value of 2.2 is not too bad of a compromise because it roughly follows the diagonal:

Note: After changing the gamma exponent value, you must click on the graph to cause it to be redrawn with the new value.
If you go to the trouble of mathematically finding the "best" gamma, you will find that its value depends on your definition of "best."

On the left we see that by minimizing the maximum error, the maximum error occurs at two locations, shown by the small vertical blue lines at L* = 4 and L* = 57.
By minimizing the RMS error, shown on the right, we are sort of minimizing the areas between the curve and the diagonal (the areas shown in light green). This method produces the minimum area, but at the expense of errors in the dark shades that are larger than those found in the case on the left.