Skip to main content
Brightness Augmentation Cannot Move Shadows or Highlights
Edge AI,  Vision Algorithm

Brightness Augmentation Cannot Move Shadows or Highlights

EDGE AI

Brightness, gamma and noise augmentation change pixel values only and cannot move shadow directions or highlight positions. Lowering the elevation from 45° to 30° shifts the highlight band on a 1 mm radius edge by about 0.12 mm, or 8 px.

For an edge model imaging machined aluminum parts at 14.9 μm/px, I calculated the changes augmentation cannot imitate, the highlight shift, the capture matrix size and condition-level holdout validation in turn.

About 11 min read

An edge model trained on dents and scratches of machined aluminum parts sometimes loses performance suddenly after the light bracket is retightened or the equipment moves to the next line. That happens even with plenty of brightness, gamma and noise augmentation in training. Trace the cause and it is usually the lighting angle that changed, not the brightness. While re-capture, relabeling and redeployment repeat, stretches of reduced inspection reliability appear, and raising the decision threshold to cut overdetection lets the finest scratches slip out quietly first.

The surface comes first. Machined aluminum returns light almost like a mirror while scattering part of it along the machining grain, so specular and diffuse reflection mix in one frame. The same dent swaps its bright and dark faces depending on where the light comes from, and on the rounded chamfer of an edge the highlight band moves with the lighting angle. So the highlight shifts and condition counts below are tied to surface roughness and curvature, and the actual values cannot be guaranteed before a sample test.

Here are the assumptions. A 4,096 × 3,000 px camera with 3.45 μm pixels and a 35 mm lens captures a 61 mm × 45 mm FOV at 14.9 μm/px from about 186 mm at the lens principal plane (a WD1 of 160 mm or more secured), looking straight down at the part. The light is a set of low-angle directional bar lights from four directions whose elevation2 can be set to 30°, 45° or 60°, the finest defect is a scratch 45 μm wide, and the edge has a rounded chamfer of 1 mm radius. Images are inferred as 48 tiles of 512 × 512 px (8 × 6) without downscaling.

Monotonic transforms cannot reverse light-dark order

Brightness augmentation takes the form I′ = aI + b and gamma augmentation I′ = Iγ, so the new value of each pixel depends only on that pixel’s original value. Brightness with a > 0 and gamma are monotonically increasing functions3, so they cannot reverse the brightness order of two pixels, and noise augmentation only adds an independent wobble to each pixel without moving any structure. All three are per-pixel augmentation4.

Under low-angle directional light, a dent images as a light-dark pair, bright on the slope facing the light and dark on the far slope. When the light azimuth5 changes by 180°, the pair swaps sides, and this order reversal, bright pixels turning dark and dark ones bright, cannot be made by any monotonic transform. Apply brightness ±20 %, gamma 0.8 to 1.25 and Gaussian noise of σ = 2 DN to 0° azimuth images, and the direction of the pair stays fixed as bright toward the light in every sample, so the model learns a dent as a pair in that direction.

Horizontal flip augmentation imitates the direction in part, but it flips the machining grain along with it and creates images that do not exist in reality. So when drawing up an augmentation list, I first ask of each item whether it is a change in value or a change in position, and changes in position are secured by capture in place of augmentation.

A 15° elevation change moves the highlight 8 px

On machined metal surfaces, the shift of specular highlights shakes the model more than shadows do. Specular reflection6 returns strongly only in the direction where the angle of reflection equals the angle of incidence, so with the camera looking straight down, the highlight forms where the surface normal tilts from vertical by (90° − elevation) ÷ 2. That is a 15° tilt at 60° elevation, 22.5° at 45° and 30° at 30°.

Seen from above, the point on a 1 mm radius rounded chamfer where the normal tilts by θ lies r × sin θ from the start of the edge. Lowering the elevation from 45° to 30° moves that point by 1 mm × (sin 30° − sin 22.5°) ≈ 0.117 mm, about 7.9 px at 14.9 μm/px, and the change from 60° to 45° still moves it 0.124 mm, 8.3 px. With a 0.5 mm radius the shift halves to around 4 px. In a setup where a 45 μm scratch is 3 px, an 8 px highlight shift is large enough to cover or reveal a whole defect.

Dent light-dark direction unchanged by brightness, gamma and noise augmentation but reversed in a real 180 degree capture, with a 3 elevation by 4 azimuth by 2 light level capture matrix and a holdout azimuth
Compare the dent light-dark direction left unchanged by brightness, gamma and noise augmentation with the direction that reverses only in a real 180° azimuth capture, and the capture matrix of 3 elevations × 4 azimuths × 2 light levels.

Saturated pixels hold no defect information in principle, so software cannot revive defects at the spot the highlight moved to. A model that learned only 45° data remembers the bright band in the middle of the chamfer as normal appearance and can see the spot the band moved to under 30° as an anomaly pattern. Darkening or brightening the band with brightness augmentation leaves its position unchanged.

Angle axes are filled only by capture

Generalization to lighting angle changes does not come from raising augmentation strength; it comes from designing a capture matrix7 with lighting conditions as its axes. Mixing many conditions without a plan only adds capture volume and leaves unclear which conditions hold up performance, whereas a matrix design spells out the elevation, azimuth and light level axes so training and validation can be split by condition.

With 3 elevations (30°, 45°, 60°) × 4 azimuths (0°, 90°, 180°, 270°) × 2 light levels = 24 conditions and 40 good plus 20 defective images per condition, the total is 1,440 images. The light level axis can be partly replaced by brightness augmentation, so with a short capture budget I would cut light levels to one and start with 12 conditions and 720 images, without cutting the angle axes. The per-pixel augmentations stay in a supporting role, filling light level deviation between conditions and sensor noise.

The matrix is a data collection plan and also a specification of the light installation tolerance. The angle range that retightening a bracket can produce has to sit inside the matrix, and an installation at an angle outside the matrix means that condition is not yet validated.

Random splits cannot measure unseen lighting

Validation uses condition-level holdout8 in place of a random split. Only by leaving one whole azimuth out of training and evaluating on it can generalization to unseen lighting conditions actually be measured. In a random split, neighboring samples of the same condition land in both training and validation and inflate performance.

In the 1,440-image matrix, one azimuth is 3 elevations × 2 light levels × 60 images = 360 images, one round of holdout validation. Run four rounds, leaving out each azimuth in turn, write the random-split results on the same data next to them, and the gap between the two shows in numbers the generalization margin for unseen lighting. I record that gap separately as the recall of the 45 μm scratch class.

Capture conditions for a 45 μm scratch in one table

Defect size, optical setup, augmentation and capture conditions are gathered in one table. The highlight shifts assume a rounded chamfer of 1 mm radius.

Item① Minimum defect size② Optical setup · WD③ Algorithm parameters
ScratchWidth 45 μm ≈ 3.0 px (14.9 μm/px)4,096 × 3,000 px, 3.45 μm pixels, 35 mm lens (magnification about 0.23), FOV 61 × 45 mm, WD 160 mm or more (object distance about 186 mm from the principal plane, measured including the space for the 30° elevation bar light)48 tiles of 512 × 512 px (8 × 6), no downscaling
DentDiameter 100 μm ≈ 6.7 px, light-dark pair about 3 px eachLow-angle directional bar lights from 4 azimuths, elevation 30° / 45° / 60°Per-pixel augmentation: brightness ±20 %, gamma 0.8 to 1.25, noise σ 2 DN (as a light level assist)
Chamfer burrLength 150 μm ≈ 10 pxHighlight shift on a 1 mm radius chamfer: about 0.117 mm (7.9 px) for 45° to 30°, about 0.124 mm (8.3 px) for 60° to 45°Capture matrix of 24 conditions × 60 images = 1,440 images; with a short budget, cut the light level axis first (12 conditions, 720 images)
ValidationRecall of 45 μm scratches tallied separatelyLight bracket installation tolerance range included in the matrixAzimuth-level holdout, 4 rounds (360 images each), recorded next to random-split results

The risk the table points to is a difference in size. At 14.9 μm/px a 45 μm scratch is about 3.0 px, while a mere 15° change in elevation moves the highlight band by around 8 px, a change more than twice the size of the defect. So the angle axes are filled by the capture matrix, and the margin for unseen lighting is measured by how far scratch recall on the 360-image azimuth holdout falls below the random split.

When no capture matrix is needed

The opposite approach clearly wins under some conditions. If the light is tolerance-managed with a fixed jig and the target is a diffuse surface, angle changes hardly occur, so single-condition capture with per-pixel augmentation is enough and a capture matrix is overkill. If the surface reflectance can be measured and rendered, synthetic images from a reflectance model (BRDF9) can partly replace angle changes, but measuring and validating the reflectance model costs extra. If omnidirectional diffuse light such as a dome can be used, removing the directionality of shadows and highlights in hardware can be cheaper than a capture matrix, at the price of weaker light-dark contrast for dents.

On surfaces where diffuse and specular reflection mix, such as machined metal, the range of appearance change with lighting angle depends heavily on surface roughness and curvature. So the number of capture conditions needed cannot be guaranteed before a sample test, and for each new part I start by measuring the highlight shift on a few samples captured at different elevations and azimuths.

Field Note

If I put an edge model on a line where the lighting can change, I validate it separately under conditions with changed bar-light elevation and azimuth. If the bracket is reassembled lower than 45°, the highlight band on the chamfer can move to a spot absent from the training data, and brightness augmentation cannot imitate that change in position. Azimuth-level holdout is my default validation, and for a new part I capture a sample matrix by lighting angle first to decide the number of capture conditions.

Field Checkpoints

Before putting a model on a new part or a new line, I check the items below. Angle-related items are never replaced by augmentation.

  • Is a WD of 160 mm or more secured by measurement, including the installation space for the 30° elevation bar light and bracket interference? (object distance about 186 mm from the principal plane)
  • Have you checked surface roughness and chamfer radius, and measured the highlight shift on samples by changing the elevation? (1 mm radius: about 8 px for 45° to 30°)
  • Is each item on the augmentation list classified as a change in value or a change in position?
  • Does the angle range that the light bracket installation tolerance can produce fall inside the capture matrix?
  • Is validation run as azimuth-level holdout in place of a random split, with both results recorded side by side?
  • Does the 45 μm scratch occupy 3 px or more, and is recall in the highlight shift zone tallied separately?

Frequently Asked Questions

Does a telecentric lens reduce the highlight shift?

Shooting with a 35 mm lens from 186 mm, the chief ray at the edge of the FOV tilts about 9.3° from vertical, so even at the same elevation the highlight condition differs between the center and the edge of the frame. A telecentric lens removes this difference within the frame, but the shift caused by a change in lighting angle remains. A telecentric lens covering a 61 mm FOV is large and expensive, so the first question is whether uniformity within the frame is really needed.

Can brightness augmentation replace the two light levels?

Light level changes are mostly changes in pixel value, so brightness augmentation imitates them fairly well. But the change in which lowering the light reveals defects inside a highlight that used to saturate cannot be made by augmentation, so for parts whose highlights saturate, I capture at least two light levels.

Glossary

  • [1] WD working distance
    The distance from the front of the lens to the surface under inspection. The roughly 186 mm in the text is a thin-lens object distance from the lens principal plane; the distance from the lens front comes from the lens drawing. ↩
  • [2] Elevation angle elevation
    The angle by which a light is raised above the horizontal plane. 30° lights at a low slant, 60° from high up. ↩
  • [3] Monotonically increasing function monotonic function
    A function whose output grows or stays the same as its input grows. It cannot change the size order of two values. ↩
  • [4] Per-pixel augmentation per-pixel augmentation
    Training data augmentation that sets each pixel’s new value from that pixel’s original value alone. Brightness, gamma and noise augmentation belong here. ↩
  • [5] Azimuth angle azimuth
    The angle that tells from which horizontal direction a light comes. A 180° change lights from the opposite side. ↩
  • [6] Specular reflection specular reflection
    Reflection that returns strongly in only one direction, at an angle equal to the angle of incidence. If the camera sits in that direction, it images as a highlight. ↩
  • [7] Capture matrix capture matrix
    A capture design that takes lighting conditions such as elevation, azimuth and light level as axes and plans every combination. ↩
  • [8] Condition-level holdout condition-level holdout
    A validation method that leaves one condition’s data entirely out of training and evaluates only on that condition. ↩
  • [9] BRDF bidirectional reflectance distribution function
    A function describing how much a surface reflects depending on the incoming and outgoing directions of light. Once measured, it lets appearance be synthesized for each angle. ↩

References

  • Formulas: pixel resolution = FOV ÷ pixel count, defect size (px) = defect size ÷ pixel resolution, normal tilt for the specular condition with a vertical camera θ = (90° − elevation) ÷ 2, highlight position on a rounded chamfer = r × sin θ, shift = r × (sin θ₂ − sin θ₁), matrix image count = elevations × azimuths × light levels × images per condition, one holdout round = elevations × light levels × images per condition, chief ray angle at the edge = atan(half FOV ÷ object distance), magnification m = sensor width ÷ FOV width, object distance = f × (1 + 1/m)
  • Assumptions: 4,096 × 3,000 px camera (3.45 μm pixels), 35 mm lens, FOV 61 × 45 mm, camera looking straight down, minimum defect 45 μm, rounded chamfer radius 1 mm (0.5 mm for comparison), elevation 30° / 45° / 60°, 4 azimuths, 2 light levels, 40 good and 20 defective images per condition

Related reading — On Moving Parts, Photometric Stereo Shrinks the Standstill Condition to 0.5 ms · Why Does a Lightweight Model Lose the Finest Defects First? · In Edge Inspection, Input Drift Shows Up Before Accuracy Drops

An engineer who has handled mechanical design and project management for production equipment since 2005. Here I work through the cameras, lenses and lighting that go into equipment with formulas and public data, and record the assumptions and sources alongside the numbers.

Leave a Reply

Your email address will not be published. Required fields are marked *