LightingTroubleshooting

Defect detection on rounded corners with uneven lighting

Fit a circle to the corner and flag deviations from a reference ring model: rounded corner defect detection that survives uneven lighting.

LumaSpec Vision12 min read Share on LinkedIn

On this page 9 sections
  1. 01Why does every good corner show a gray ring in the image?
  2. 02Which light makes the corner ramp smallest?
  3. 03How do you build a reference model of a good corner?
  4. 04How many pixels does a corner defect really need?
  5. 05What threshold separates a pit from the normal ramp?
  6. 06Can a smart camera run the ring test on the line?
  7. 07When does the ring model fail?
  8. 08What do you check before ordering the lighting?
  9. 09Questions

A rounded corner is the hardest place on a part to inspect with a fixed threshold. As the surface curves, its normal sweeps through the illumination angle, so gray level ramps from dark to bright along the arc even on a perfect part, and the real defect — a shallow pit, a dent, a tool mark — hides inside that ramp. This guide is for quality and process engineers who inspect stamped, machined or molded corners and keep fighting a gray ring that follows the geometry. You will shrink the ramp by changing the lighting geometry, then detect the defect as a relative deviation from a fitted reference corner instead of an absolute gray cutoff, and set the threshold from measured noise rather than trial and error. One camera, one diffuse light and about thirty good parts are enough to build it.

Why does every good corner show a gray ring in the image?

A rounded corner sweeps the surface normal through 90 degrees along the arc, so any light with a dominant direction sees glancing incidence at one end and a near-specular return in the middle, and gray level ramps across the whole transition band even on a perfect part. The ring is geometry, not dirt. The law of reflection returns a lamp's rays to the camera only where the local surface normal bisects the angle from light to camera, and along a corner arc exactly one band satisfies that condition; bright field vs dark field lighting works through the same rule. Everywhere else on the arc the surface sends light away from the sensor and reads darker. A pit adds a local dip of tens of gray levels on top of the ramp, but a fixed threshold at 150 gray levels cannot separate the dip from the ramp simply crossing 150, so it flags the whole band, defect or not. That is the ring you are fighting. Escape it optically, by flattening the ramp, or algorithmically, by comparing against a model of it.

Bright-field and dark-field lighting geometry High-angle light reflects off the flat surface straight into the lens, so the surface looks bright. Low-angle light reflects away from the lens, so the surface looks dark and only edges or scratches scatter light upward.flat part with a scratchCamerabright field(high angle)dark field (low angle)flat areas reflect away;only the scratch sends light up
Bright-field and dark-field lighting geometry. High-angle light reflects off the flat surface straight into the lens, so the surface looks bright. Low-angle light reflects away from the lens, so the surface looks dark and only edges or scratches scatter light upward.
Symptom Most likely cause Test Fix
Same band flags on every good part Fixed threshold meets the curvature ramp Run 20 known-good parts; the band sits at the same normalized radius each time Reference subtraction, next sections
Band drifts as parts shift The ramp moves with the part; a stored flat-field cannot follow Jog one part ±0.5 mm in the fixture and watch the band move Fit the model to each part's own edge
Pits near the outer edge missed Directed light saturates the glancing zone Histogram at the outer band pinned above 240 Lower the incidence angle or go diffuse
Detection flickers shot to shot Under-exposure, gain amplifying noise σ above about 6 gray levels inside the annulus More light on the sensor, less gain

Which light makes the corner ramp smallest?

A diffuse dome light shrinks the ramp the most, because every point of the arc sees light arriving close to its own normal; a 0-degree coaxial light is the next choice where the corner is shallow and the surrounding flat faces must stay glare-free. A directed bar or spot at a fixed angle concentrates the mirror band exactly where geometry puts it. A dome replaces that one direction with a hemisphere of directions, so the sharp band widens into a gentle plateau. The sizing rule, an estimate from dome geometry: choose an emitting diameter of about twice the part width, which keeps the field edges lit from within roughly 45 degrees of the local normal. Go smaller and the field edges darken like a directed light again. A part up to about 55 mm wide therefore wants roughly 110 mm of emitting area. The LS-DOM-0085 provides an Ø116 mm emitting area inside a Ø166 mm housing, with the camera looking in through the top opening.

How a dome light works LEDs at the rim light the white inner surface of the dome, which lights the part evenly from almost every direction. The camera looks through a hole at the top; on flat mirror-like areas the hole reflects as a dark spot.Cameradiffuse inner surfacelights the part from every sideLED ringcamera holecurved or wrinkled part; dark spot where the hole reflects
How a dome light works. LEDs at the rim light the white inner surface of the dome, which lights the part evenly from almost every direction. The camera looks through a hole at the top; on flat mirror-like areas the hole reflects as a dark spot.
Dome lightsØ166 mm dome light, Ø116 mm emitting area (LS-DOM-0085)LS-DOM-0085
Size
100-200 mm
Voltage
24 V
from $409.00View partBuild a system with it

On shallow corners — a sheet-metal bend, a rounded label corner on a flat face — a coaxial light is often enough. Its rays travel parallel to the optical axis and return straight back from surfaces facing the camera, so flat faces read bright and the curved corner darkens smoothly, and a smooth ramp is one the model handles happily. For small parts, the LS-CXL-0027 is a 60 x 60 mm coaxial light, listed at 4.4 W in red and 7.2 W in white. On polished metal, keep the dome as the primary fix and add a polarizer on the lens; lighting shiny metal pins without glare walks through that combination. Dark matte curved parts behave differently again, as black rubber inspection lighting for curved handles shows, and the full dome story, wrinkles included, is in dome lights for shiny, curved and wrinkled parts. Browse emitting sizes in the dome lights and coaxial lights categories.

How do you build a reference model of a good corner?

Threshold the part boundary, fit the smallest enclosing circle to the corner arc, average about 30 known-good images in corner-centred polar coordinates, and use the smoothed mean gray versus normalized radius as the model every new part is compared against. Every step below is a few lines in any vision library:

  1. Segment the part. Threshold background from part; the corner arc must come out as a clean, closed edge.
  2. Fit the circle. Take the smallest enclosing circle of the arc pixels, or a least-squares fit, and record its centre and radius.
  3. Build the annulus. Inner radius R − w, outer radius R + w, where w is the measured ramp width plus a 10-pixel margin.
  4. Remap to polar coordinates. Around the fitted centre, gray becomes a function of the normalized radius ρ = r / R, which removes the corner's position from the picture.
  5. Average the good parts. Mean the profiles of about 30 known-good parts and smooth them; that curve M(ρ) is the model.
  6. Compare per pixel. Divide each new part's remapped image by M(ρ); the result should sit near 1 everywhere except at defects.
d = (I - M) / M flag if |d| > t, t = max(4σ, 0.10)

The circle fit is what makes the method position-independent: the model travels with the part, so ±0.5 mm of fixture drift costs nothing. If your library has a dynamic-threshold operator, the same idea applies along the radius instead of across the image; scratch defect detection with lighting and dynamic thresholding shows the flat-surface twin of this method.

How many pixels does a corner defect really need?

Size the pixels from the smallest defect you must catch, not from the camera you already own: three pixels across the defect is the working minimum, so a 0.3 mm pit needs 0.1 mm per pixel, which a 26 mm window meets with 260 pixels. The arithmetic, for a 26 mm wide inspection window on a 3072-pixel-wide sensor: p = 26 mm / 3072 px = 0.0085 mm per pixel, and a 0.3 mm pit spans 0.3 / 0.0085 ≈ 35 pixels — ten times the minimum. That tells you the useful truth about corners: pixels are almost never the limit, gray contrast is. Run the ladder the other way instead. A 0.1 mm scratch wants 0.033 mm per pixel, so the same window needs about 780 pixels of width; a 0.05 mm crack wants about 1560. Below 0.05 mm the optics usually give up before the sensor does.

p = FOV_width / sensor_pixels_width pixels_across = defect_mm / p (want ≥ 3; 5+ to measure)
Camera resolution for the smallest feature
Units
Pixels needed
–
Sensor size
– MP
Smallest sensor that fits
–
Pixel on the part
– mm
Pixels across the feature, that sensor
–

Pixels needed = field / feature × pixels per feature on each axis (field incl. margin). The lens must resolve the pixels too: Nyquist = 1000 / (2 × pixel µm) lp/mm.

Find cameras with enough pixels Open the full calculator

The pixel rule in full, with its own worked examples, is in camera resolution for defect detection.

What threshold separates a pit from the normal ramp?

Detect on the relative deviation image and set the threshold from the noise you measure, not by eye: flag when the relative deviation |I − M| / M exceeds the larger of 4σ and 0.10, which with a typical σ of 0.03 gives a threshold of 0.12. Worked example with illustrative numbers you would replace with your own measurements: stamped bracket, corner radius 8 mm, 26 mm window, 0.0085 mm per pixel. On a good part the model at the ramp's mid-radius reads M = 128 gray. A good pixel measures 124: d = (124 − 128) / 128 = −0.031, well inside a threshold of 0.12. A 0.4 mm pit, about 47 pixels across, darkens the same pixel to 84: d = (84 − 128) / 128 = −0.344 — flagged with nearly 3× margin. On the same image a fixed threshold at 150 gray flags every pixel whose ramp value crosses 150: an entire arc-shaped band on every part, defect or not.

Clean the flag image with an opening of about 5 pixels, then keep connected components of at least 20 pixels; the 47-pixel pit survives with room to spare. Measure σ as the standard deviation of d across the annuli of your 30 training parts. If σ grows past 0.05, fix the lighting before touching t — no threshold rescues a noisy image, the point robust machine vision lighting argues at length.

Can a smart camera run the ring test on the line?

Yes, as long as the region of interest stays small: edge threshold, circle fit, polar remap, model division and relative threshold are a few dozen image operations, and current smart cameras close them in around 100 ms for a 300 × 300 pixel ROI. Treat that 100 ms as an order-of-magnitude budget, not a data-sheet figure. The annulus of a 10 mm corner at 0.0085 mm per pixel is a few hundred pixels across, so every step after segmentation runs on a small fraction of the sensor. The polar remap and division are per-pixel arithmetic, and the circle fit runs on edge points. What pushes you to a PC is variety, not speed: a model library across dozens of part numbers, several corners in one image, or traceability storage. On the line, choose a mono sensor — color buys nothing on a gray-on-gray defect and costs sensitivity.

All three of these run the loop on the device; the table pulls the deciding rows from the data sheets.

Specification MV-SC5060XM-08M-WBN HK-TD032-12-WBN LS-SMC-0017
Communication protocol TCP, UDP, Modbus, Serial Port, PROFINET, EtherNet/IP, Fins, MC, FTP, etc. RS-232, TCP, UDP, FTP, PROFINET, Modbus, EtherNet/IP, MELSEC/SLMP, FINS, Keyence KV –
Sensor type CMOS, rolling shutter CMOS, global shutter 1" CMOS
Pixel size 2 μm × 2 μm 3.45 μm × 3.45 μm 3.45 μm
Sensor size 1/2.4" 1/2.9" –
Resolution 3200 × 1920 1408 × 1024 –
Max. frame rate 15 fps 60 fps –
Gain 0 dB to 34 dB 0 ~ 15 dB –
Exposure time 72 μs to 150 ms 16 μs ~ 1 sec –
Pixel format Mono 8 Mono 8 –
Mono/color Mono Mono –
Memory 8 GB – SC: 2G (optional 4G) / SC(E): 4G
Data interface Gigabit Ethernet (1000 Mbit/s) Fast Ethernet (100 Mbit/s) –
Price $1,629.00 $1,699.00 $1,359.00

Values as printed in each product's data sheet; open a part for its drawing and full specifications.

The smart cameras category splits by interface and resolution, and the camera finder filters directly by pixel count.

When does the ring model fail?

The ring model assumes the corner images as a circular arc viewed face-on; once the part tilts more than roughly 15 degrees, perspective squashes the arc into an ellipse, and a circle fit leaves residual error larger than the defect signal itself. Fix the tilt in the fixture, or fit an ellipse to the arc and remap in elliptical coordinates — same pipeline, one different fit. Beyond that, the failures are practical rather than mathematical:

  • Inside fillets. A corner inside a deep pocket shadows itself; no light from the camera's hemisphere reaches the surface, and neither dome nor coaxial helps. That is a low-angle or a 3D job.
  • Raised defects. A burr lifts gray instead of dropping it, which is exactly why the flag tests the absolute value of d.
  • Deep, shadowing pits. Under any directional component a deep dent reads differently shot to shot; if the geometry itself is the signal, move to a profile sensor — improving shiny metal 3D point cloud capture starts there — or to photometric stereo with two to four quadrant-switched illumination directions.
  • Wrong neighbourhood. A defect on the flat right next to the arc falls outside the annulus; widen w or add a second window on the flat, as in lighting for metal surface defect inspection.

What do you check before ordering the lighting?

Before ordering anything, confirm three numbers on your own parts: the corner radius and ramp width in pixels, the smallest defect diameter in mm, and the gray-level noise σ across 30 good parts; together they fix the dome size, the sensor resolution and the threshold. Measure them on your own parts, and each one settles one purchase decision:

  • Ramp width in pixels. One profile plot across a good corner sets the annulus half-width w and shows whether the ramp is gentle enough to model at all.
  • Smallest defect diameter. On the 26 mm window used above: 0.3 mm needs a window about 260 pixels wide, 0.1 mm about 780, 0.05 mm about 1560.
  • Noise σ over 30 good parts. Below 0.03 means the threshold math works as printed; above 0.05, change the light first.
  • Emitting area versus part width. About twice the part width for a dome; the light finder filters domes and coaxials by size.
  • Trigger plan. A short strobe that freezes the part in the window; free-running cameras and continuous light let ambient drift inflate σ.

Start the hardware side in the light configurator, and skim the rest of the lighting topic for the geometries you meet less often. If the part fights back, send a corner radius, a defect size and one good image through the contact page — that is enough for a first lighting pick.

Questions

Does a polarizer remove the gray ring on a corner?

Only partly. A crossed polarizer suppresses the band where the surface reflects at the right polarization angle, but a corner sweeps that geometry continuously, so part of the arc stays bright whatever you do. Use a polarizer in addition to diffuse dome lighting on polished parts, and let the ring model be the primary defense.

Why not average many frames to flatten the lighting?

Frame averaging removes noise that varies with time, such as flicker and sensor noise, but the corner ramp is fixed in space: it follows the part's curvature and repeats identically on every frame. Averaging a hundred images converges to the same non-uniform picture, so the fix must be in the lighting geometry or in a reference model.

Can flat-field correction from a blank master replace the reference model?

No. Flat-field divides the image by a stored shot of a uniform, evenly reflective master, so it corrects the light's own falloff. The corner ramp is produced by the part's curvature, moves with every fixture shift, and a stored flat image cannot follow it. The per-part circle fit exists precisely for that reason.

Which light colour works best for gray defects on gray metal?

Red or infrared usually wins. Stains, oils and oxidation reflect differently in the blue, while the gray defect and the gray metal stay close across wavelengths, so dropping blue raises the defect's relative contrast. Dome lights are commonly stocked with 850 nm and 940 nm infrared options, which also sit outside visible room lighting.

How many good parts does the model need?

Thirty known-good parts is a practical floor, and the useful check is the residual noise σ, which stops improving noticeably much beyond that. Keep two inspected golden parts on a shelf and re-run the model weekly; if σ grows over time, clean the dome window and re-check the working distance before touching the threshold.