System designExplainer

Edge tool threshold and quality: how projection sets the score

Why a lower contrast threshold can drop an edge tool's quality score, how projection and density shape that number, and how to set a threshold that behaves.

LumaSpec Vision11 min read Share on LinkedIn

On this page 10 sections
  1. 01What a projection edge tool actually measures
  2. 02Contrast threshold gates crossings; binary threshold moves them
  3. 03Worked example: why the score fell from 20.9 to 12
  4. 04Predicting the score before you run it
  5. 05Density: what 1000 versus 500 really changes
  6. 06Choosing a threshold that behaves in production
  7. 07Where you set these parameters
  8. 08When a projected edge tool is the wrong tool
  9. 09Checks before you trust the number
  10. 10Questions

Drop the contrast threshold on an edge tool and the quality score of the found edge can fall from about 21 to about 12, on an image where not one pixel changed. That is not a bug. The score is the gray-level contrast of whichever crossing wins the search, and the threshold decides which crossings are allowed to compete. Once you can picture the projected profile the tool is really working on, you can predict the score on paper, place the gate between your real edge and your worst artifact, and decide what the density setting should cost you. This page is for anyone programming edge finds on smart cameras or in PC vision software.

What a projection edge tool actually measures

Every projection-based edge tool does the same first step, whatever the vendor calls it. It scans the region of interest line by line, sums the gray values in each line, divides by the pixel count of that line, and keeps one number per line. The 2D region collapses into a 1D intensity profile along the line index, and an edge that runs parallel to the scan lines appears as a step or ramp between two levels.

That step is exactly the technique behind summing image rows to build a stable intensity profile, and it buys real noise immunity. Because each profile sample averages a whole line, the level does not depend on the ROI width, while the noise on it falls with the square root of the pixels averaged. Position resolution is one image row, scaled to the part by your magnification.

The trade-off is built in: anything not parallel to the scan lines smears across several samples, and any other feature inside the ROI — a shading dip, a second part, a label seam — adds its own crossing to the same profile.

Contrast threshold gates crossings; binary threshold moves them

The two threshold types look alike in the parameter list and do opposite things.

A binary threshold is a gray level. The edge position is defined where the projected profile crosses that level, so changing the level slides the edge along the transition ramp. Binary thresholding is the classic one-level split of a grayscale image into two classes (thresholding in image processing), and choosing the level is the same judgment call as picking an auto-threshold method for grayscale images.

A contrast threshold is a gray-level difference. The tool locates each transition, takes its steepest point as the position and its plateau difference as the contrast, then rejects transitions whose contrast falls under the gate. Lowering a contrast threshold never moves an existing crossing. It only admits weaker ones. So the instinct most engineers carry here is correct: a binary threshold relocates the edge, a contrast threshold cannot.

On the worked profile below, the transition falls at 2.6 gray levels per row — 21 gray levels across 8 rows. Dropping a binary level by 5 gray levels slides the reported edge 5 / 2.6 = 1.9 rows, with no change in the part. A contrast threshold cannot produce that slide at any setting.

Binary threshold Contrast threshold
The value is a gray level a gray-level difference
Lowering it slides the edge down the ramp admits weaker crossings
Position where the profile crosses the level steepest point of the transition
Uniform brightness drift plateaus move, crossing walks difference unchanged, crossing stable
Typical failure mode drift moves the edge off tolerance an artifact crosses the gate

The split generalizes across vision: a threshold gates candidates and a score grades them. The same structure appears in pattern match score thresholds, where the coarse search gates the result, and in sorting parts by score threshold in robot vision.

Worked example: why the score fell from 20.9 to 12

Illustrative profile, close to what shaded parts produce. The ROI is 240 lines tall and 600 pixels wide, and the single-pixel noise is 5 gray levels. Rows 1-60 are flat background at 150.0 gray levels. A smooth shading dip bottoms out at 138.0 gray levels around rows 61-80, then background resumes. The part edge transitions over rows 161-168, and the part plateau reads 129.0 gray levels from row 169.

The arithmetic that follows:

  • Ripple contrast: 150.0 - 138.0 = 12 gray levels, at two crossings (down and up).
  • Real edge contrast: 150.0 - 129.0 = 21 gray levels.
  • Noise per profile sample: 5 / √600 = 0.20 gray levels.
  • Noise on a plateau estimated from 40 clean lines: 0.20 / √40 = 0.03 gray levels, about ±0.05 on the contrast.

Run 1, contrast threshold 20. The ripple crossings read 12, under the gate, and are rejected. The real edge reads 21, clears the gate, and wins. The tool reports a quality of about 20.9 — the measured plateau difference, 0.1 gray levels under the ideal 21.0 and comfortably inside the noise band.

Run 2, same image, contrast threshold 4. The first ripple crossing now reads 12, clears the gate, and sits earlier in scan order, so it wins the slot you were watching. The reported score falls to 12 (the real edge is still in the list, at about 21). No pixel changed. The candidate set did.

This is also the honest answer to the density question that usually follows: the density setting changes which lines build the profile, which moves every plateau a few tenths of a gray level. That matters only when a crossing sits within a few gray levels of the gate — precisely the situation a low threshold creates.

Predicting the score before you run it

You do not need the tool's internals to predict its score. The projected profile is enough.

expected_quality = plateau_bright - plateau_dark sigma_line = sigma_pixel / sqrt(N_pixels) sigma_plateau = sigma_line / sqrt(n_plateau_samples)

Measure the two plateaus on a live image — most tools chart the profile, and otherwise 20 averaged rows of flat background give the number by hand. Their difference is the quality that crossing will report: 150 - 129 = 21 gray levels on the worked profile, and the 20.9 you saw is that number minus line noise.

Then work the worst case, not the nominal one. If defocus, light drift or part finish can cut the real contrast to 16 gray levels on a bad day, the gate must sit under 16, not under 21. Last, read the unit your library prints: a strong step edge that reports close to the plateau difference is grading in gray levels; one that reports near 1.0 for every strong edge in any lighting is grading normalized. The logic is unchanged — only the scale of the numbers moves.

Density: what 1000 versus 500 really changes

Density is the fraction of ROI lines the tool scans, in per mille: 1000 scans every line, 500 every second line, 100 every tenth. The setting typically runs 100 to 1000, and many tools ship a default of 500 — a speed setting inherited from slower hardware, not an accuracy recommendation.

Halving density does three things, in rising order of pain:

  1. Plateau estimates use half the samples, so their noise grows by √2 — on the worked profile from about ±0.05 to about ±0.07 gray levels, negligible against a 21 gray-level edge.
  2. The transition is sampled coarsely, so subpixel interpolation of the position gets noisier. This is the cost that shows up first in a capability study.
  3. A feature one line wide — a seam, a hairline crack parallel to the scan lines — can fall entirely between scanned lines and never produce a crossing at all.

The decision follows the station type. Score-critical measurement, or anything hunting thin features: scan every line, density 1000, unless the cycle budget is genuinely closed. Presence checks with strong, wide edges: 500 is fine and buys speed. Whatever you choose, run it at production speed after the change, because the profile — and with it every contrast — shifts with the setting.

Choosing a threshold that behaves in production

Place the gate between the crossings you must reject and the crossings you must keep:

C_spurious = strongest crossing to reject (gray levels) C_real_min = weakest crossing to accept, worst case (gray levels) threshold = C_spurious + (C_real_min - C_spurious) / 2 margin_each_side = (C_real_min - C_spurious) / 2 >= 3 x sigma_contrast

On the worked profile: C_spurious = 12, C_real_min = 21, so threshold = 12 + 9 / 2 = 16.5, with 4.5 gray levels of margin each side against a contrast noise of ±0.05. As a working rule keep at least 3 gray levels of margin each way; below that, contrast noise and illumination drift start flipping decisions from part to part.

If the artifact and the real edge overlap in contrast, do not fight it with the gate — clean the profile instead. Flatten the illumination, lengthen the ROI so each plateau has at least 10 clean lines, and keep every other feature out of the region. Where your library filters the result list by quality afterwards, detect low and accept high — the two-level idea behind hysteresis thresholding — so a weak real edge stays visible while artifacts still fail.

The contrast gate is also your defense against brightness drift. A uniform light change moves both plateaus together and leaves the difference alone. That is why a contrast threshold rides through the conditions described in controlling ambient light variation in pick-and-place vision, while a binary threshold's crossing walks with every drift.

Where you set these parameters

On the device, these settings live in the smart camera's inspection software: an edge find with its contrast gate, tuned in the parameter tree, running on a global shutter that keeps the geometry honest on moving parts. The smart cameras category carries the range, and the camera finder filters it by resolution, shutter and mount.

Smart cameras & vision sensorsHikrobot MV-SC6050C-08M-XBN SC6000 Series Smart Camera, 5 MP, Color, 8 mm focal length, M12-mount, Multi-color light sourceMV-SC6050C-08M-XBN
Interface
GigE
Resolution
5 MP
Sensor format
1/1.45"
Shutter
Global
$3,449.00 · quotedView and quote
Code readers & vision sensorsSmart cameras & vision sensors

Inspection on the device, no PC

350 models · from $169.00

On the PC side, the same tools run in vision software on a controller with camera ports and built-in light channels — the usual home for multi-camera stations and heavier inline logic. The vision controllers page lists that range, and the system configurator matches camera, lens and controller in one pass.

Vision controllersHikrobot MV-VC3301H-128G66 I3-8100, 8GB+128G SSD, No PoE, PCIe expansion supported, Incl. VM6200Pro licenseMV-VC3301H-128G66
LAN ports
5+ LAN ports
USB 3 ports
3-4 USB 3 ports
Light outputs
4 built-in channels
Memory
8 GB
$2,419.00View partBuild a system with it
ComputersVision controllers

Vision computers and fanless industrial PCs

190 models · from $1,119.00

When a projected edge tool is the wrong tool

The projection assumes an edge parallel to the scan lines. Past a few degrees of tilt, the transition smears over more samples, the steepest point drifts, and marginal crossings sink toward the gate. Align the ROI so the edge runs parallel, or move to a 2D edge or line fitter that fits geometry across the whole region instead of collapsing it first.

Two more cases call for a different tool. A curved or shaded surface whose ripples rival the real contrast is the territory of adaptive thresholding for uneven part shading rather than one global gate. And geometry built from several edges needs per-crossing quality limits and a proper fit, as in corner position measurement with two edge lines.

Where the projected tool fits — straight, parallel edges, controlled light, one transition class per ROI — it is hard to beat for speed and stability.

Checks before you trust the number

  • Chart the projected profile once and read both plateaus. Expected quality = their difference, in gray levels.
  • Run one offline scan at a deliberately low threshold and list every crossing. Label each one real or artifact and record its contrast.
  • Set the threshold midway between the strongest artifact and the weakest worst-case real edge, with at least 3 gray levels of margin each way.
  • Set density 1000 for score-critical stations, and confirm the score spread over 20 or more production parts stays inside the calculated noise band.
  • Read the whole result list, not slot one — a low threshold changes which crossing wins the first slot.
  • After any lighting or optics change, re-read the plateaus. The difference between them is the only number the gate sees.

If a threshold still misbehaves in production after this, talk to the applications team with the profile chart and the score log, and the systems topic page collects the related reading on thresholds, profiles and scores.

Questions

Does lowering the contrast threshold move the edge position?

No. In contrast mode the position stays at the steepest point of the projected transition and only the candidate list changes. A binary threshold behaves the other way: the edge sits where the profile crosses the level, so each 1 gray level of change slides the position by 1/slope rows — on a ramp of 2.6 gray levels per row, about 0.4 rows per gray level.

What minimum quality should I accept for a found edge?

Set the floor at about two thirds of the ideal plateau difference. On a 21 gray-level edge that is a floor of 14: a nominal edge reports about 21, drift or defocus that cuts the real contrast to 16 still passes, and a shading ripple at 12 fails. Log the scores per part so the floor tracks evidence, not feeling.

Why do two runs on the same part give slightly different scores?

Profile samples are line averages, so each carries the single-pixel noise divided by the square root of the pixels in the line; live parts add illumination variation on top. Fix the exposure and gain so the plateaus cannot wander, scan every line, and estimate each plateau from as many clean lines as the ROI allows — the spread then collapses to the calculated noise band.

Is a higher quality score always the more correct edge?

No. Quality measures contrast, not relevance: a shadow edge or a printed border can out-contrast the feature you want and take the first slot. Constrain the ROI to one transition class, order the search deliberately, and accept a crossing only where its position fits the model — a 12 gray-level edge in the right place beats a 21 gray-level shadow in the wrong one.

Can I lower density to speed up the cycle time?

Yes, and scan cost falls roughly in proportion to the fraction of lines scanned. The price is coarser subpixel position and the chance that a one-line feature falls between sampled lines and is never seen. Lower it for presence checks with strong, wide edges; keep every line for measurement stations, then confirm the score spread on production parts before you sign the station off.