Imagine deploying an autonomous mobile robot (AMR) in a warehouse with dim aisles and deep shelves. Its camera can see a carton inside a dark rack, but the resulting image is so dark that the carton label and edges are difficult for the vision system to distinguish. Increasing the camera exposure may reveal the carton, yet it can also turn nearby reflective pallet wrap into a featureless white patch. Image enhancement changes the recorded brightness or color values so useful evidence is easier to separate without moving anything in the image.
1. What is Image Enhancement?
Image enhancement changes pixel intensities or colors so that task-relevant structure becomes easier to see or measure. This tutorial explains global gamma and normalization, local CLAHE, and white balance, then shows how to use them through Pupil.
Enhancement is not restoration. It does not know the true surface brightness, and it cannot recover information lost to clipping, defocus, motion blur, or insufficient resolution. It changes the representation of the captured signal. That can make a threshold, edge detector, OCR model, or human operator more effective, but it can also amplify noise and make weak artifacts look important.
The engineering question is therefore not “does the enhanced image look better?” It is “does the transformation make the next measurement more stable without hiding or fabricating evidence?”
1.1 The Enhancement Pipeline
Captured intensities → more usable contrast
Enhancement redistributes captured evidence; it cannot reconstruct detail that was clipped, blurred, or never sampled.
Start on the left with the image recorded by the AMR’s camera. The carton may already be present in the pixels, yet its printed label uses only a few nearly black intensity values. In a home, warm kitchen lights may instead make a humanoid see every neutral worktop with an orange cast. The first problem is low contrast; the second is unbalanced color.
The next step is to look at how those values are distributed. Gamma correction can use a fixed curve, normalization can use the darkest and brightest values, and CLAHE can measure many small regions separately. That measurement answers a practical question: which parts of the available range are crowded together and need more room?
The chosen mapping then replaces each old pixel value with a new one. Importantly, it does not move the pixel. The label stays in the same place and keeps the same outline; only its stored brightness or color changes. The output is therefore easier for a later threshold, edge detector, OCR model, or person to read, but it contains no new scene geometry.
This also explains the main risk. Enhancement can spread real detail apart, but it can spread noise apart too. It cannot recover a letter that was clipped to black or blurred away by the camera. The rest of this section examines the different mappings and the evidence each one can—and cannot—improve.
1.2 Gamma Correction: Bend the Intensity Scale
Return to the warehouse AMR looking into a dark shelf. The camera image contains faint differences between the carton, its label, and the shadow behind it, but those differences are crowded into a small range of dark pixel values. Simply adding the same number to every pixel would also brighten the already visible pallet wrap and could turn it completely white.
Gamma correction is useful because it can expand the dark part of the brightness scale more than the bright part. The robot gains more numerical separation between shadowed surfaces without applying the same increase everywhere.
Think of gamma as a curve between input brightness and output brightness. Every input pixel looks up its new value on that curve. By bending the curve upward, we can separate dark values that were crowded together; by bending it downward, we can reduce overly bright midtones.
To describe one curve independently of whether the image uses 8-bit or floating-point storage, first normalize an input intensity to the interval . A common power-law mapping is
Here, is the input intensity, is the output intensity, and controls the curve. When , dark inputs move upward and shadow differences become easier to see. When , midtones move downward. At , nothing changes.
Interactive mechanism
Remap intensity without moving pixels
Gamma is nonlinear: equal input steps do not remain equal output steps. Lifting shadows spreads dark values apart but compresses some brighter values together. If the dark region contains sensor noise, gamma correction spreads that noise too.
Automatic gamma correction estimates a value from image luminance statistics. This is convenient when exposure varies, but it makes the output depend on what the camera sees. A large black object entering the image may change the estimated correction even if illumination is unchanged. Validate stability over time when enhancement feeds a tracking or control loop.
1.3 Global Normalization: Use More of the Available Range
Now imagine an industrial arm inspecting matte gray castings under diffuse lights. The image is neither especially dark nor bright, but the part and conveyor occupy only values 80 to 140 in an 8-bit image that could use 0 to 255. The camera has captured differences, yet it represents all of them with only sixty intensity levels.
Normalization answers this different problem by stretching the occupied range. Gamma bends the scale; normalization expands the selected low and high values toward new endpoints.
Global normalization stretches the observed low and high values toward chosen output limits. Dark values become farther from bright values, making global contrast easier to measure. Unlike gamma, the simplest form is a straight-line mapping between the two ranges.
Min–max normalization maps an observed interval into a target interval :
is the original pixel, is the normalized pixel, and and are the selected input limits. If most values occupy 80–140 in an 8-bit image, mapping that interval toward 0–255 increases global contrast.
The weak point is the statistic. One hot reflection can set and leave the rest compressed. Percentile-based limits are more robust but deliberately clip some extremes. Global normalization also cannot fix an image whose left side is dark and right side is bright: one mapping is applied everywhere.
Use normalization when the whole image has a consistent but underused range. Record how limits are estimated, because a fixed mapping and a newly estimated mapping for every camera image behave very differently over time.
1.4 Histogram Equalization: Redistribute Values by Frequency
Consider a drone photographing a large composite aircraft panel. Most of the image contains nearly uniform material, while a much smaller region contains fasteners and surface marks. Normalization sees only the lowest and highest values; it does not notice that most pixels are crowded into a narrow group between them. A linear stretch may therefore leave the important material differences compressed.
Histogram equalization responds to how frequently each brightness occurs, not only to the endpoints.
The idea is to give frequently occupied intensity ranges more room and sparsely occupied ranges less room. To do that, the algorithm first counts how many pixels use every intensity. This count is the grayscale histogram.
Let be the normalized frequency of level . Its cumulative distribution is
is the fraction of pixels no brighter than level . Histogram equalization maps intensity using this cumulative value, spreading frequently occupied ranges across more output levels.
This creates contrast where the image contains many similar pixels, but a global histogram still mixes regions with different lighting. It can also strongly amplify noise in a nearly uniform area because small random variations are the only available differences.
1.5 CLAHE: Enhance Local Histograms Without Unlimited Amplification
Imagine a cobot picking parts from a logistics tote. One side of the tote sits beneath a lamp while the other lies in shadow. One global brightness mapping cannot serve both regions well: a correction strong enough to reveal the dark side may over-enhance the bright side.
CLAHE allows different parts of the image to receive different contrast mappings.
Contrast Limited Adaptive Histogram Equalization, or CLAHE, solves this by working locally. It divides the image into tiles and builds a separate histogram mapping for each one. A label inside a dark tile can therefore be enhanced without forcing the same aggressive change onto the bright background.
Local adaptation introduces a new danger: a nearly uniform tile may contain mostly sensor noise, and equalization could make that noise look like strong texture. CLAHE’s contrast limit clips overly concentrated histogram peaks before the mapping is built. The algorithm redistributes the clipped mass and interpolates between neighboring tile mappings so tile borders do not become visible seams.
The local tiles solve the uneven-lighting problem: a shadowed label and a bright background can receive different mappings. The clip limit prevents one narrow noisy peak from receiving unlimited contrast. The tile grid size controls spatial scale. Fine tiles respond to small lighting changes but risk emphasizing texture and noise; coarse tiles behave more like global equalization.
Interpolation between tiles matters because applying unrelated mappings abruptly would create visible seams. CLAHE blends the neighboring transfer functions so the output changes smoothly across tile boundaries.
For color images, enhancing RGB channels independently can alter hue. Applying CLAHE to a lightness-like channel in LAB allows chromatic channels to remain more stable. This is why the Pupil Skill exposes color_space="lab" as a useful choice for color scenes.
1.6 White Balance: Correct a Color Cast, Not Brightness Alone
Now move to a humanoid sorting dishes beneath warm kitchen lights. A white cup may appear orange in the camera image even though its brightness is adequate. Gamma and contrast expansion cannot solve this because the problem is the balance between red, green, and blue, not the overall amount of light.
White balance estimates how strongly the red, green, and blue channels should be scaled so that a surface believed to be neutral is represented as neutral. Under an ideal neutral illuminant, a gray surface should have similar red, green, and blue values. Real lamps and camera processing disturb that balance.
A simple gain model is
are input channels, are estimated gains, and the primed values are corrected channels. Automatic methods make assumptions such as “the scene average is neutral” or “the brightest unsaturated surfaces are near white.” Those assumptions fail in a scene dominated by one real color.
White balance is especially important before color thresholding. If the camera’s own auto-white-balance remains active while software also corrects every image, two adaptive systems can fight each other. For repeatable robotics, controlled illumination and fixed camera settings are usually preferable; software correction handles residual variation.
1.7 Read the Histogram Before Choosing a Mapping
Suppose an image from a cobot inspection camera looks dark on screen. Before adding enhancement, the engineer needs to know whether the camera recorded subtle differences that can be expanded or clipped the entire region to black. The histogram is useful because it separates these two cases.
An image can look dark for two very different reasons. In the first case, useful pixels are present but crowded into a narrow low-intensity interval. In the second, the sensor clipped them to black and recorded no differences at all. Enhancement can help the first case; it cannot reconstruct the second.
A histogram makes this distinction visible. A narrow mound away from the endpoints suggests that contrast can be expanded. A spike at zero suggests shadow clipping. A spike at the maximum value suggests highlight clipping. Several separate mounds may correspond to materials, illumination regions, or foreground and background, but the histogram alone does not say which interpretation is correct because it discards pixel position.
Always inspect the image beside its histogram. A small bright reflection may create a histogram tail that is numerically real but irrelevant to the task. Conversely, a tiny printed label may occupy too few pixels to form an obvious mound even though it is the only region the robot needs to read.
The same caution applies to color histograms. A channel distribution can reveal a color cast or unused range, but it cannot tell whether that color belongs to the target, the background, or the lamp. Statistics propose a mapping; the physical task decides whether it is useful.
1.8 Enhancement Order Changes the Result
A warehouse AMR may need white-balance correction for the aisle lighting and CLAHE for a shadowed shelf. Applying both is reasonable, but their order matters because the first operation changes the pixel distribution measured by the second.
Enhancement operations are generally not interchangeable. If gamma correction is applied before CLAHE, it changes the local histograms from which CLAHE builds its mappings. If white balance follows clipping, increasing a channel gain cannot recover values already saturated. If denoising follows strong local contrast enhancement, the enhancement may first exaggerate noise and make it harder to separate from real texture.
A practical order is to fix image formation first, then representation: stabilize exposure and white balance, remove known sensor noise if necessary, and finally apply the smallest contrast adjustment that improves the next task. This is not a universal recipe—some denoisers work better after normalization—but it gives each operation a clear reason to exist.
Preserve both the raw and processed images while tuning. When a downstream detector fails, compare them and ask whether the evidence was absent in the camera image, lost during preprocessing, or merely interpreted incorrectly. Without the raw image, an attractive enhanced result can hide the true source of failure.
1.9 Choosing the Right Operation
The mechanisms now fit into a decision process. Begin with the failure you can observe in the raw camera image, then select the smallest operation that directly addresses it. The table summarizes that mapping from symptom to tool.
| Problem observed | Start with | Why | Main failure mode |
|---|---|---|---|
| Whole image too dark or bright | Gamma correction | Nonlinear control of shadows and midtones | Amplifies dark noise |
| Values occupy a narrow global range | Intensity normalization | Expands the available range | Outliers dominate limits |
| Contrast varies across the image | CLAHE | Uses local tile statistics | Amplifies texture or creates unnatural contrast |
| Neutral surfaces have a color cast | White balance | Adjusts relative channel gains | Scene-color assumptions may be false |
Do not stack operations automatically. White balance, CLAHE, gamma, and normalization can each alter statistics used by the next. Add one operation at a time and measure the downstream effect.
2. How to Enhance an Image in the Telekinesis Agentic OS
The concepts above become useful when each operation has a specific job in the deployed pipeline. This example begins with local contrast enhancement because the assumed problem is uneven illumination. It then shows automatic gamma as an optional second step, not a default operation that should always be stacked.
from telekinesis import datatypes, pupil
image = datatypes.Image.from_url(
url="https://assets.telekinesis.ai/examples/v1/images/dark_warehouse.jpg"
)
enhanced = pupil.enhance_image_using_clahe(
image=image,
clip_limit=2.0,
tile_grid_size=8,
color_space="lab",
)
corrected = pupil.enhance_image_using_auto_gamma_correction(
image=enhanced,
)
print(corrected.shape)
Begin by testing CLAHE alone. Add automatic gamma only if varying global exposure remains a measured problem. Inspect intermediate images and record parameters so a later regression can identify which mapping changed.
3. How to Evaluate Enhancement
An enhanced image should be judged by what it enables, not by whether it looks dramatic. Build a validation set containing shadows, highlights, target absence, color casts, and noise. Measure the next task: OCR accuracy, threshold stability, edge localization, feature matches, or model confidence calibration. Also check clipped-pixel rate and image-to-image variation over time.
An enhancement that improves average accuracy but causes occasional extreme false positives may be unsuitable for robot motion. Preserve the raw image alongside the enhanced version during debugging; enhancement should remain a reversible pipeline decision, even when its pixel mapping is not mathematically invertible.
4. Where to Go Next
5. References
- Zuiderveld, K. “Contrast Limited Adaptive Histogram Equalization”, 1994.
- Telekinesis. “Enhance Image Using CLAHE”, Pupil Skill documentation.
- Telekinesis. “Enhance Image Using Auto Gamma Correction”, Pupil Skill documentation.

