Black contaminants on a dark steel plate are the hardest blob target in routine inspection: the plate reads around gray 30-45 and the contaminant 25-40 on the same 8-bit image, so every threshold you try merges specks with mill-scale texture. The fix is not a cleverer threshold. You change the image, then you change the blob logic: a bar light at a grazing angle makes any raised or rough contaminant scatter light into the camera while the flat plate reflects it away, and a two-step blob model keeps the search inside the plate. This walkthrough gives the geometry, the gray-level rule that tells you when thresholding cannot work, a worked example with lens, light and strobe numbers, and the blob settings that separate texture from real defects.
Why no threshold can separate them
A threshold draws one line through the gray histogram and asks both classes to sit on opposite sides of it. At zero gain, sensor noise alone spans about 2 gray levels, and mill-scale texture spreads the plate class by another 6 to 8. When the contaminant class overlaps the plate class by ten levels, the two distributions share most of their pixels, and every cut misclassifies thousands of texture pixels as defects.
Measure before you tune anything: sample a 20 x 20 pixel patch on clean plate and one on a known contaminant, then compute the gap. The working rule:
That is a gap of 20 gray levels. Adaptive and local-mean methods remove background drift across the plate, but they cannot split distributions that overlap — local mean adaptive thresholding shows where those methods do win. Dark specks on a light background are the easy case, solved by plain dark speck detection; dark-on-dark is a lighting problem wearing an algorithm's clothes. Below a 20-level gap, stop tuning the threshold and change the image — the same call made in glass bottle defect detection.
Low-angle dark field flips the contrast
Mount a bar light almost parallel to the plate, 10 to 20 degrees above the surface. A flat plate at that angle mirrors the light away from the camera, so the steel reads near black, 15 to 30 gray levels. A contaminant with rough texture, a raised edge or a different reflectance scatters light into the lens and reads 40 to 80 levels above the plate. The overlap is gone because you are no longer comparing brightness; you are detecting which points break the mirror.
Set the angle from the geometry:
A bar 100 mm above the plate with its far edge 350 mm along the surface sits at atan(100 ÷ 350) = 16 degrees. One bar lights one direction, so scratches parallel to the beam stay invisible: fit a second bar at 90 degrees, or take a second exposure with the part rotated, and OR the two blob masks. Bare bright steel also glints — copper surface inspection lighting covers that fight — and large field of view lighting covers brightness across wide plates. Use a direct, high-luminance bar from the bar lights range, not a diffused one: diffusion exists to fill shadows, and here the shadows are the signal.
The direct bar to start from for the plate in the worked example:
- Size
- 200-400 mm
- Type
- Standard
- Voltage
- 24 V
The LS-BAR-0400 is a 312 x 30 mm high-luminance bar on 24 V. That 312 mm lit length spans the 300 mm plate width used below.
The two-step blob inspection, step by step
Run two blob models in sequence: a plate finder, then a size-limited defect search inside it. The structure is the same in every blob tool; blob locator with conditional logic walks it in a ladder-style robot-vision implementation.
-
Lock exposure and gain. Commission the station with fixed exposure and gain at zero, triggered from the PLC. Auto exposure chases the plate and drags your threshold set-point with it — the drift pattern is described in auto-exposure ROI instability.
-
Model 1, the plate finder. Threshold the plate against the conveyor or backdrop and take the largest blob as the plate. Compute the expected plate area in pixels (plate width ÷ pixel size × plate height ÷ pixel size) and accept the plate only at 99 percent of it or better. Below that, something on the plate reads outside the plate gray band and the part fails even when no small blob appears. This area gate catches gross damage; small specks belong to the next step.
-
Model 2, defects inside the plate ROI. Constrain the blob search to the plate blob from step 2, so conveyor texture never reaches the candidate list. Set the minimum blob area near the pixel count of your smallest defect — an 8 to 12 pixel floor kills one- and two-pixel noise — and a maximum area just above your largest tolerable contaminant, so edge fragments and reflections are rejected instead of merged.
-
Set the blob count limit high. Allow at least 100 blobs. Tools that stop searching at the limit silently drop every defect beyond it.
-
Prove it with planted defects. Mark a clean plate with a 0.5 mm graphite dot, a 1 mm oil drop and a hair across the grain. Run 50 images: all planted defects found, zero blobs on the clean plate. If texture still blobs, raise the minimum area before you touch the threshold.
Worked example: 300 x 200 mm steel plate, 0.5 mm contaminant
Inputs:
- Plate: 300 x 200 mm dark mill-scale steel; classes overlap by about ten gray levels under even lighting (plate 30-45, contaminant 25-40).
- Smallest contaminant to catch: 0.5 mm across; largest tolerable: about 2 mm.
- Camera: a 5 MP smart-camera sensor, 2,448 x 2,048 pixels, 3.45 µm pitch.
- Working distance: 500 mm, set by the machine guard.
- Worst-case motion: 200 mm/s as the plate settles into the nest.
Two rules drive every number: sample the smallest defect with at least 3 pixels across — the same sampling limit behind edge position accuracy from image sampling — and keep the light between 10 and 20 degrees.
- Field of view with margin: 300 mm + 10 percent = 330 mm wide; 200 mm + 15 percent = 230 mm high.
- Pixel size on the object: 330 ÷ 2,448 = 0.135 mm per pixel (the wide axis governs; the height gives 230 ÷ 2,048 = 0.112).
- Sampling check: 0.5 ÷ 0.135 = 3.7 pixels across the smallest contaminant — passes.
- Blob window: a round 0.5 mm speck covers π × (0.25 ÷ 0.135)² ≈ 11 pixels. Set the minimum blob area to 8 pixels and the maximum to 200 pixels, a speck of diameter 2 × √(200 ÷ π) × 0.135 ≈ 2.2 mm.
- Lens: sensor width = 2,448 × 0.00345 mm = 8.45 mm; magnification m = 8.45 ÷ 330 = 0.0256; focal length f = 500 × 0.0256 ÷ 1.0256 = 12.5 mm — order a 12 mm lens:
- Light: the 312 mm lit length spans the 300 mm plate width; mounted 100 mm up and 350 mm back along the surface, the bar sits at 16 degrees.
- Strobe: one pixel of blur allows t ≤ 0.135 mm ÷ 200 mm/s = 0.7 ms. Set the strobe pulse to 500 µs; if the nest holds the plate still, 2 ms also works.
- Plate-area gate: 300 × 200 = 60,000 mm² = 2,222 × 1,786 ≈ 3.97 million pixels. The 1 percent tolerance is 39,700 pixels ≈ 600 mm², a missing circle 28 mm across. The gate catches gross damage; the blob window carries everything smaller.
Decision: order a 312 mm high-luminance bar and a 12 mm lens, strobe the bar at 500 µs, gate on plate area at 99 percent, and run blobs from 8 to 200 pixels inside the plate. Below 0.45 mm this station runs out of sampling: 0.4 ÷ 0.135 = 2.96 pixels, just under the rule. Split the plate across two stations or step up to a 12 MP sensor for smaller specks.
Choosing the light, camera and controller
| Geometry | Plate reads | Contaminant reads | Verdict |
|---|---|---|---|
| Low-angle bar, one side | 15-30, near black | 40-80 levels higher | The fix for raised or rough specks |
| Second bar at 90 degrees | dark | bright in at least one exposure | Add it when scratches run one direction |
| Steep ring or coaxial bright field | mid-gray, glinting | darker or brighter by reflectance | Use it for flush films and stains |
| Dome or diffused bar | even gray | even gray | Wrong here: it erases the shadows you need |
Direct versus diffused, same size class:
| Specification | LS-BAR-0400 | LS-BAR-1276 |
|---|---|---|
| Price | $459.00 | $439.00 |
All 2 share: Cable length 500 mm. Values as printed in each product's data sheet; open a part for its drawing and full specifications.
Take the direct bar for this job. On cameras, pick monochrome, pick global shutter if the line moves, and prefer a C-mount so the focal length is your choice. The LS-SMC-0017 is an 8.8 MP camera with global shutter and a C-mount. That mount lets you fit the 12 mm focal length computed above instead of a fixed-lens unit. The rest of the range sits under smart cameras.
The strobe wants a controller channel with microsecond timing into a 24 V bar. For that channel, the controller used in most single-camera stations:
- LAN ports
- 5+ LAN ports
- USB 3 ports
- 3-4 USB 3 ports
- Light outputs
- 4 built-in channels
- Memory
- 8 GB
Four built-in light channels leave spares for the second bar at 90 degrees and a backlight if the nest needs one. The wider range sits under vision controllers.
Checks before you order
- Plant a 0.5 mm graphite dot and re-measure the gap under the final dark-field set-up: at least 20 gray levels, or drop the bar to 12 degrees and add the second bar.
- Bar lit length at least the plate width; inspect both plate ends, where bar uniformity falls away.
- Shade the station and test with room lights off: overhead light striking at a grazing angle looks exactly like your bar — machine vision stray light shows how to trace it.
- If the plate can move under the camera, confirm global shutter and size the pulse the way high-speed barcode verification sizes its strobe.
- Run the planted-defect test and the 50-image clean run before the purchase order, not after.
When dark field still is not enough
Escalate in order. First the second bar at 90 degrees: one-directional scratches are the most common miss, and scratch defect detection with dynamic thresholding covers the directional-light trick in depth. Second, combine fields: published polished-surface inspection pairs a bright-field and a dark-field exposure of the same station and fuses them, because a real defect breaks at least one of the two lighting models. Third, when texture variance still buries 11-pixel blobs, hand the image to a learned defect segmenter and keep the rule-based plate gate in front of it; troubleshooting a YOLO blob-detection output covers the traps at that stage.
Short checklist
- Gray gap at least 20 levels between contaminant and plate under the final lighting.
- Bar lit length at least the plate width; elevation between 10 and 20 degrees.
- At least 3 pixels across the smallest defect; blob minimum area near its pixel count; maximum at your largest tolerable speck.
- Plate-area gate at 99 percent of expected; blob count limit at least 100.
- Strobe no wider than one pixel of blur; exposure and gain locked.
- 50 clean images with zero blobs; every planted defect found.
The configurator matches a camera, lens, light, light controller and cables to each other, step by step, and lists only parts that fit what you already picked.
The configurator walks light, lens and camera in that order — feed it the plate width, defect size and working distance from this page. If the station is already failing on your line, send one image and the two gray readings via the contact page and we will size the bar, lens and strobe with you.
Questions
Does raising camera gain or brightness separate the two gray classes?
No. Gain multiplies both classes by the same factor, so a 10-level overlap becomes a 20-level overlap at 2x gain, and sensor noise grows with it. Brightness and gamma controls do the same. Only a change in how light reaches the contaminant versus the plate — geometry, wavelength or polarization — moves one class without the other. Touch gain last, and only to use the full 8-bit range.
What if the contaminant is a flat oil film with no raised texture?
Dark field misses flush films because nothing scatters toward the lens. Swap geometry: light the plate near-perpendicular, coaxially or with a steep ring, so the steel's own reflection brightens the plate, then threshold the oil as a dark or discolored region inside the bright plate. Oils and mill scale also differ in the near-infrared, so an 850 nm bar with a monochrome camera often splits classes that white light cannot. Run both geometries as two exposures if both defect types matter.
How high should the maximum blob count be set?
Above the worst defect count you ever expect, with margin. If the worst plate you will pass carries 20 contaminants, set the count to 100. Tools that stop searching once the limit is reached silently miss defects beyond it, and a limit of 5 or 10, a common default, truncates exactly the bad plates you are trying to catch. Review rejected images monthly and raise the limit whenever a list looks capped.
What resolution do I need for a 0.3 mm contaminant on a 300 mm plate?
Three pixels across the defect means 0.1 mm per pixel, so 300 mm of plate needs 3,000 pixels across the sensor: a 12 MP class camera of about 4,000 x 3,000 pixels in one shot. A 5 MP sensor at 2,448 pixels wide gives 0.12 mm per pixel, which puts 0.3 mm at 2.5 pixels — detectable sometimes, not reliably. The honest options are a 12 MP camera, two camera stations, or accepting 0.4 mm as the limit.
Will a diffused bar or dome light do the same job more gently?
No — they work against you here. Diffusion and domes exist to erase shadows and specular glints, and dark-on-dark detection lives on those shadows. A diffused bar spreads each LED's ray bundle, the grazing cone widens past 20 degrees, and the plate starts reflecting into the lens again. Reserve domes for shiny curved parts where glare, not contrast, is the enemy. Keep the direct bar for flat dark plates.

