A gray pixel can receive different output values after histogram equalization even when its own recorded value stays unchanged. The transformation depends on how many other pixels occupy each intensity level. Changing the surrounding image can therefore change the mapping applied to the pixel.

That dependence separates global histogram equalization from applying one fixed tone curve to every image. It also explains why a more dramatic display does not establish that the camera recovered previously missing detail.

OpenCV's version 4.12.0 tutorial constructs a cumulative histogram and an intensity lookup table, then distinguishes global equalization from local adaptive processing. The scikit-image 0.25.2 equalize_hist reference documents how a mask can select the pixels used to estimate equalization while the result applies to the whole image. These are source definitions, not outputs generated for this article.

Declare a small mapping completely

Consider an invented grayscale image with eight possible input and output codes, zero through seven. Use eight recorded pixels:

2, 2, 2, 2, 3, 3, 4, 5.

Their spatial arrangement is intentionally unspecified. This example studies a global histogram, which counts values regardless of where they occur.

Let F(k) be the fraction of pixels with code at most k. At the occupied levels 2, 3, 4, and 5, F is respectively 0.5, 0.75, 0.875, and 1.

For this original calculation, define a particular lookup rule at occupied levels:

T(k) = round_half_up[7 × (F(k) − F_min)/(1 − F_min)].

F_min is the cumulative fraction at the lowest occupied level, here 0.5. Round_half_up means rounding to the nearest integer with an exact half rounded upward. This declared rule makes the small example reproducible. It is not a claim about the exact rounding or output of either cited library.

Calculate the lookup before interpreting the image

For input 2, the numerator F(k) − F_min is zero, so T(2) = 0.

For input 3, the unrounded result is 7 × 0.25/0.5 = 3.5, giving T(3) = 4. For input 4 it is 5.25, giving T(4) = 5. Input 5 maps to 7.

The output record is therefore:

0, 0, 0, 0, 4, 4, 5, 7.

The available output range is used more widely than the original range from 2 through 5. But the output histogram is not flat: four pixels still occupy one level, two occupy another, and two individual pixels occupy two more levels.

A deterministic global lookup cannot split four identical input codes into four different output codes. In this example, equalization redistributes the occupied levels without making the number of pixels at every possible output level equal.

The same input code can move

Now construct another eight-pixel image:

2, 3, 3, 3, 3, 3, 3, 5.

Its lowest occupied cumulative fraction is 1/8. At level 3, the cumulative fraction is 7/8. Using the same declared rule gives:

T(3) = round_half_up[7 × ((7/8) − (1/8))/(1 − (1/8))] = 6.

A code of 3 mapped to 4 in the first image and maps to 6 in the second. The pixel's original code did not change. The population used to construct the lookup changed.

For an illustrative decision rule that accepts an equalized code of at least 5, that same input code would fail in the first image and pass in the second. This is a consequence of the hypothetical threshold and mappings, not an inspection recommendation.

A fixed threshold after per-image equalization consequently has a distribution-dependent interpretation. Altering a background region, crop, or estimation mask can matter even if the particular target pixels are retained unchanged.

A global histogram does not encode geometry

Rearrange the first eight pixels in any spatial order. Their cumulative fractions and lookup remain identical. A compact region of level 3 and two separated level-3 pixels receive the same transformation under this global rule.

The transformed image still retains the original positions of its pixels. However, the histogram that determined the lookup did not describe their connectivity, shape, or physical identity.

This is why a contrast transformation alone cannot establish whether a bright region is a defect, a reflection, or an intended marking. Equalization supplies an intensity mapping, not a semantic explanation.

Keep information loss separate from contrast expansion

Suppose an earlier acquisition stage recorded two physically different locations as the same code 3. Any deterministic lookup based only on that recorded code maps both to the same output value. Expanding the numeric separation between other codes does not recreate the distinction lost between those two locations.

Later quantization can merge retained levels too. For a separate toy example, use four equally populated, ordered input levels but only three output levels, zero through two. Under the analogous normalized cumulative rule, the unrounded outputs are 0, two-thirds, four-thirds, and 2.

Nearest rounding gives 0, 1, 1, and 2. Two distinct input levels now share one output code. This deliberately reduced output alphabet demonstrates the issue without claiming that every equalization implementation necessarily merges the same levels.

The constant-image case needs its own definition

If every recorded pixel has the same code, F_min equals 1. The displayed normalization formula then has a zero denominator and requires a separate handling rule.

That mathematical special case is not evidence of a defect in a cited library. Implementations define their behavior separately. Regardless of the chosen constant output, applying one code-to-code lookup to a uniform input cannot reveal a previously absent spatial pattern.

More contrast is therefore a statement about the retained codes and transformation. It is not a measurement of additional scene information.

Preserve the mapping's context

A reproducible robot-image record can identify the image or mask used to form the histogram, the output range, the cumulative normalization, and the rounding convention. Those definitions explain why the same input can have different transformed values.

The original examples make the useful boundary explicit: global equalization can spread recorded intensity levels according to their population. Its visual effect depends on that population, and it does not recover distinctions that the recorded image no longer contains.

Sources checked October 23, 2026

OpenCV 4.12.0, Histograms: Histogram Equalization, versioned official tutorial:

https://docs.opencv.org/4.12.0/d5/daf/tutorial_py_histogram_equalization.html

scikit-image documentation displayed as 0.25.2, exposure.equalize_hist and histogram:

https://scikit-image.org/docs/0.25.x/api/skimage.exposure.html

All records, code ranges, rounding rules, and decisions above are original hypothetical examples. No image-processing software was executed to produce these results.

Illustration note: An accompanying generic robot camera or vision-workstation image is a concept illustration. It does not show the invented histogram, a measured equalization result, or a validated inspection decision.