A robot inspection program averages two image values and reports one brightness number. That arithmetic can be perfectly implemented while answering a different question from the average of the underlying linear responses. The difference arises when the stored values have passed through a nonlinear transfer function.

The key question is which domain is being averaged. A mean of encoded values is a valid statistic of those values. It is not automatically a mean light response, even if the resulting image looks smooth and plausible on a display.

Define a reversible example first

Let x be a normalized linear grayscale response between zero and one. For this original mathematical example, define an encoding y = square root of x. Its inverse is x = y squared.

Ignore noise, clipping, black-level offsets, quantization, color channels, spatial optics, and all other processing. Use exact real-valued arithmetic initially. This simple exponent is chosen to make the operations visible; it is not an assertion that a particular camera or PNG file uses this transfer function.

Basler's Gamma documentation describes brightness processing for display with a power relationship. W3C's PNG Third Edition distinguishes encoded samples from decoded values and describes reversing gamma encoding before its example of compositing. Those references motivate identifying the transformation; they do not supply the invented pixels below.

Two pixels reveal an order dependency

Consider two equally weighted linear responses: x1 = 0.04 and x2 = 0.64. Their linear mean is (0.04 + 0.64)/2 = 0.34.

Encoding the individual responses gives y1 = 0.20 and y2 = 0.80. The arithmetic mean of the encoded values is 0.50. Decoding that mean gives 0.50 squared = 0.25.

The decoded encoded-domain mean, 0.25, differs from the original linear mean, 0.34. Neither calculation involved an implementation bug or lost precision. The averaging and nonlinear transformation simply do not commute.

If the purpose is to represent the linear mean with an encoded output, encode 0.34 after averaging. The result is approximately 0.583095. That is different from the encoded mean of 0.50, even though both originated from the same pair of pixels.

A number labeled average brightness therefore needs to preserve which of these operations produced it. It cannot identify the intended physical interpretation by its label alone.

The difference follows a simple identity

For this particular square-root encoding, let a and b be the two linear inputs. Squaring their average encoded value gives:

[(square root of a + square root of b)/2] squared = (a + b + 2 square root of a b)/4.

Subtract that result from the linear mean (a + b)/2. The difference is (square root of a - square root of b) squared divided by four. It is nonnegative, and it is zero when the inputs match.

For a = 0.04 and b = 0.64, the difference is (0.20 - 0.80) squared/4 = 0.09, which matches 0.34 - 0.25.

This identity is specific to the chosen mapping and equal weights. It does not establish a universal numerical correction for arbitrary transfer functions, tone mappings, or collections of pixels. It explains this example's result from its assumptions.

Equal means can conceal different structure

Compare a second two-pixel patch whose linear values are 0.34 and 0.34. Its linear mean is also 0.34, but each encoded value is approximately 0.583095, so its encoded mean is approximately 0.583095.

The first patch and the uniform patch have equal linear means yet different encoded means. A threshold on encoded patch means can consequently distinguish them partly because of the response distribution within the patch, rather than because their linear averages differ.

The opposite ambiguity is possible too. A patch with linear values 0.25 and 0.25 encodes to 0.50 and 0.50. Its encoded mean equals the first patch's 0.50, while its linear mean is 0.25 rather than 0.34.

One encoded average alone cannot reveal which distribution was present. Retaining the individual values preserves information needed for the inverse operation before averaging.

A single threshold is a narrower case

The assumed square-root function is strictly increasing. For one pixel, x greater than 0.25 is equivalent to y greater than 0.50 under exact arithmetic. A correctly transformed single-pixel threshold can therefore describe the same decision.

That equivalence does not justify using the same conversion after averaging encoded values. The earlier patch example changes the operation between transformation and decision. A monotonic pointwise mapping does not make every later statistic invariant.

This distinction matters when a robot image pipeline moves an operation across a display conversion. A threshold on individual pixels, a threshold on patch means, and a threshold on filtered data are different mathematical procedures, even if their parameter fields all contain the word brightness.

Know the function before undoing it

The example uses a pure square root and square. Actual image encodings may use piecewise functions, lookup tables, offsets, or multiple stages. The square-root model is not the exact sRGB transfer function, and a parameter named gamma does not uniquely identify every system's convention.

W3C's specification explains metadata and decoding rules for PNG representations. A file extension by itself does not prove that arbitrary pixel values are linear scene measurements. Likewise, Basler's documented controls and availability are model-specific; the article does not prescribe a camera configuration.

Clipping and rounding add further limits. An invertible mathematical curve cannot recover distinctions that another processing stage already merged. Increasing numerical precision after such a loss does not recreate the missing observations.

Choose the statistic for the task

An encoded-domain mean can be appropriate when the intended quantity is explicitly the mean of those encoded codes. There is no requirement that every robot algorithm use a linear light-domain statistic. The requirement is that its meaning and training or calibration conditions remain consistent.

When the intended quantity is a mean linear response under a known model, decode the retained samples, form that mean, and apply any desired output encoding afterward. The original two-pixel calculation demonstrates why the order matters, without establishing a camera calibration or a robot inspection acceptance threshold.

Image note: The accompanying site-library robot and parts-bin scene is a conceptual illustration of imaging. Its blue sensing pattern is not a gamma test, measured pixel distribution, or validated inspection result.

Sources checked October 23, 2026:

Basler, Gamma, accessed documentation footer version 137, released October 19, 2026: https://docs.baslerweb.com/gamma

W3C, PNG Specification Third Edition, Recommendation June 24, 2025, Sections 12.1, 13.13, 13.16: https://www.w3.org/TR/png-3/

All response values, averaging identities, threshold comparisons, and interpretation: original ZHILIANHAI editorial analysis.