A crack segmentation routine — threshold, morphology or a trained model — hands you a binary mask, but the line still needs numbers: how long the crack is, how wide, and what area it covers, in millimetres rather than pixels. This guide walks the measurement chain from mask to report: the skeleton-based width and length formulas, a mm-per-pixel scale you can defend, the camera and lens arithmetic that puts enough pixels across a 0.15 mm crack, and the bias checks that keep the numbers honest. The worked example runs a 12 MP camera over a 120 mm field at the scale derived below, and every formula works on the same mask no matter how segmentation was done.
What do you need before a crack mask becomes millimetres?
You need three things in place before the mask means anything in millimetres: a binary mask worth measuring, a skeleton running down its middle, and a mm-per-pixel scale from a target photographed in the part plane — width then computes as 2 × area ÷ skeleton length.
- A binary mask that deserves measuring. Every number below inherits the mask's errors, so if cracks and background noise are not cleanly separated yet, fix that first — the crack segmentation guide covers the separation step.
- A skeleton. A one-pixel centreline inside the mask. Classical skeleton methods for thick strokes find these core pixels first and thin everything else away, which is what makes width computable rather than guessed. Get the polarity right before trusting it (skeletonizing line patterns) and trim the fuzz (removing spurs but keeping the longest line).
- A scale in mm per pixel, photographed in the part's plane. Area survives without it — pixel counting alone gives relative area (blob area by pixel counting) — but width and length in millimetres do not.
Skip any of the three and the report reads pixels pretending to be millimetres.
What are the steps from binary mask to width, length and area?
Skeletonize the mask, then compute area as the pixel count, length as the skeleton's path length and mean width as 2 × area ÷ skeleton length; at the worked scale, an 8,400-pixel mask with a 1,120-pixel skeleton reads 7.56 mm², 33.6 mm and 0.45 mm.
The sequence, end to end:
- Clean the mask. Fill pinholes and delete specks under 20 px. Log what you removed so a genuine micro-crack never vanishes silently.
- Skeletonize the mask to its one-pixel centreline.
- Prune spurs shorter than 5 px. They are threshold raggedness, not real branches.
- Count the mask pixels — this is the area A, in px.
- Measure the skeleton path length L, in px, counting each diagonal step as √2. Counting diagonals as 1 makes a 45° line read 29% short.
- Convert with the pixel scale s (mm per px): area = A × s², length = L × s.
- Read width twice: mean width as 2 × area ÷ length, and the local width profile from the distance transform along the skeleton (next sections).
Worked example, used throughout this guide: A = 8,400 px, L = 1,120 px, s = 0.03 mm per px.
- Area = 8400 × 0.03² = 8400 × 0.0009 = 7.56 mm²
- Length = 1120 × 0.03 = 33.6 mm
- Mean width = 2 × 7.56 ÷ 33.6 = 0.45 mm
The units check out: mm² divided by mm leaves mm. The pixel-side mechanics of these steps — and the pitfalls of reading width straight off a mask — are in measuring crack width from an image in pixels and mm; what follows adds the scale and the optics that turn those pixels into defensible millimetres.
How do you set a millimetres-per-pixel scale you can trust?
Photograph a certified target lying in the part plane and divide its known length by the pixels it spans: a 30 mm scale bar spanning 1,000 px, with ±1 px of end-detection error contributing about ±0.2%.
Three habits keep that scale honest:
Same plane, same height. Lay the certified scale bar in the part plane, at part height — not on the fixture bed below it. Height offsets move the scale; the tilt-and-height section below puts a number on that.
Recompute per span, and mind the ends. s comes from that one division; ±1 px per end makes the span 998-1,002 px, so s moves ±0.2%. Area inherits the square: ±0.4%. Width inherits it linearly, which on the 0.45 mm example is ±0.001 mm — negligible next to edge error.
Recalibrate when anything moves. New focus position, swapped lens, new fixture: re-shoot the bar. It costs one image.
For markers, grids and a full camera model, the camera calibration walkthrough with image markers goes further than a single bar.
How many pixels do you need across the narrowest crack?
Keep 3 to 5 pixels across the narrowest section you must report, which caps the field of view at 120-200 mm for a 0.15 mm crack on a 4,000-pixel sensor; anything coarser turns a width measurement into a presence check.
The arithmetic behind the rule: subpixel edge fitting localizes each edge to roughly ±0.3-0.5 px, so a 3 px crack carries up to ±33% width error while a 5 px crack holds near ±20%. Inverted for scale: s ≤ w_min ÷ 5 to quantify, s ≤ w_min ÷ 3 to detect. For w_min = 0.15 mm that is s ≤ w_min ÷ 5 to quantify and s ≤ 0.05 mm per px to detect — on a 4,000-pixel sensor, fields of 4,000 × s = 120 mm and 4,000 × 0.05 = 200 mm.
To size the whole camera around defect size rather than one crack, the pixels-per-defect sizing guide for crack detection runs the same budget from the other direction. At this scale, the set-up quantifies 0.15 mm cracks with 5 px and still detects 0.09 mm ones at 3 px.
Which camera and lens put that scale at a practical working distance?
Work the pixel budget backwards through the lens equation: that 120 mm field on a 4,000-pixel camera is delivered by a 16 mm lens at about 275 mm working distance on a 7.4 mm wide 1/1.7-inch sensor — an ordinary bench setup, not a special order.
The field is already fixed: 120 mm wide at scale s on a 4,000-pixel sensor. A 1/1.7-inch sensor is about 7.4 mm across (the inch convention is nominal; ±0.2 mm of sensor width moves the computed working distance about ±7 mm, which focus adjustment absorbs), so magnification m = 7.4 ÷ 120 = 0.0617. With a working distance the fixture can hold at 275 mm, focal length f = WD × m ÷ (1 + m) = 275 × 0.0617 ÷ 1.0617 = 16.0 mm. Running a stock 16 mm lens forward: WD = 16 × 1.0617 ÷ 0.0617 ≈ 275 mm, and the field checks out at 7.4 × (275 − 16) ÷ 16 ≈ 120 mm.
Two stock parts fill the bill.
- Sensor format
- 1/1.7"
- Interface
- USB3
- Type
- Machine vision fixed
- Sensor format
- 1.1"
The LS-CMR-0166 supplies the 4000 × 3000 array at 30 fps over USB3. The LS-FFL-0567 is a 16 mm C-mount lens covering 1.1-inch, 20 MP sensors with an F2.8-22 iris and under 0.3% distortion. Its image circle leaves margin over the 1/1.7-inch format.
Hold the working distance as the fixture's promise, and test that promise at part height — the tilt-and-height section sizes the error. When the deliverable is a pass/fail width limit rather than a stream of measurements, the same skeleton maths runs on-board a smart camera, and one device replaces camera, lens and PC.
How do you measure width on a crack that branches or tapers?
Split the skeleton into branches: report the longest path as the crack's length, add the branches for total length, and read local width from the distance transform — twice the inscribed radius, so a 9 px radius here is a 0.54 mm local width.
Build the skeleton as a graph first: nodes at junctions and endpoints, edges between them. Then the three readings stop fighting each other:
- Main length is the longest path through the graph: 860 px × s = 25.8 mm here.
- Total length is every branch summed: 260 px of side branches add 7.8 mm to reach the 33.6 mm total.
- Local width comes from the distance transform of the mask evaluated on the skeleton: w(x) = 2 × DT(x) × s. The 9 px peak here is 2 × 9 × s = 0.54 mm.
Report median and maximum alongside the mean: 0.42 mm median, 0.45 mm mean, 0.54 mm max describes a tapering crack better than one number. The taper reads directly off the profile — 0.30 mm at the hairline tip (DT 5 px) opening to 0.54 mm at the mouth (DT 9 px).
One correction keeps junctions honest: the distance transform spikes where arms meet, inflating any average that includes junction pixels. Exclude skeleton points whose DT exceeds twice the median before averaging. When the same crack is tracked across inspections, measuring crack growth from image sequences builds on these same skeleton endpoints.
How do you keep the threshold from biasing the width?
Set the threshold halfway between the background and crack gray levels: with a 30-level step spread over 3 px, a threshold 5 levels off moves each edge half a pixel and biases width by a full pixel, while the halfway rule cancels that symmetric error.
The mechanism, sized: a crack edge is a gray ramp, and the binary edge sits wherever the threshold crosses it. A gradient of 10 levels per px means a threshold 5 levels off walks each crossing half a pixel outward — 1 px on width, about 7% on the 0.45 mm example.
The halfway rule removes most of that: threshold at the midpoint between background and crack-bottom levels, and symmetric blur displaces both crossings equally, cancelling in the width. Contrast is the other lever — 10 levels per px is thin, so brighter or more grazing light on the crack steepens the ramp and each level of threshold error buys back proportionally less edge.
Lock the illumination so the midpoint stays put: constant-current LED drive, and a bandpass filter with matched red LED light to strip ambient drift. With stable contrast and subpixel crossing interpolation, ±0.3 px per edge is a realistic working figure.
When does a 2D crack area count lie to you?
A flat, in-plane part is the assumption behind every number above: tilt the crack plane 10° from perpendicular and widths inflate by about 1.5% (1/cos 10° = 1.015), raise the part 1 mm off the calibrated plane at 275 mm WD and the scale drifts about 0.4%.
Tilt. Width across an inclined crack scales as 1 ÷ cos θ: +1.5% at 10°, +6.4% at 20°. Beyond that, stand the camera off-normal or correct the projection.
Height. The scale is valid only on the calibrated plane. Off it by Δh, magnification moves by Δh ÷ (WD − f): on the 275 mm set-up that is 1 ÷ 259 ≈ 0.4% per mm. A Ø50 mm cylinder under a 40 mm field makes the point: the rim sits 25 − √(25² − 20²) = 10 mm nearer the lens than the top, so rim scale runs about 10 ÷ 259 ≈ 3.9% hot. Curved parts need zoned or tilted cameras — or telecentric optics, whose magnification ignores part height.
The LS-TCL-0574 is a 0.4× fixed-magnification lens with 227 mm working distance in C-mount.
- Sensor format
- 1.2"
- Mount
- C-mount
- Image circle
- 16-22 mm
On the 7.4 mm sensor it covers 7.4 ÷ 0.4 = 18.5 mm, which the 4,000-pixel array divides to 0.0046 mm per px: a 0.10 mm crack spans about 22 px, and the width stops moving when the part flexes a millimetre. The trade is field — 18.5 mm per shot against 120 mm — so telecentric suits critical zones, stitched passes or smaller parts.
Which checks prove the numbers before the system ships?
Before sign-off, measure a machined slot of known width, rotate the part 90° to prove the scale is isotropic, sweep the threshold ±10 levels and re-shoot the scale bar after every focus or height change; on this setup those checks bound width error to roughly ±0.5 px per edge.
Run these six, and rerun 1, 4 and 5 at each maintenance interval:
- Scale on the day. Image the 30 mm bar, recompute s, log it against the image set. One image, one minute.
- Physical cross-check. Image a machined slot or gauge shim of known width; the reading must land within one pixel of the shim's known width. For the gauge side of that comparison, this walkthrough of measuring a machined slot width with CMM and pin gauges shows how the physical number is obtained.
- Isotropy. Rotate the target 90°. The x and y scales must agree within 0.5%, or pixels are not square and area is wrong by the same skew.
- Height window. Lift the part 1 mm off the plane: width may move less than 0.4%. Fixture the part inside whatever window that test passes at.
- Threshold sweep. Step the threshold ±10 levels around the halfway point. Width may move at most one pixel; a bigger swing means weak contrast — fix the lighting, not the threshold.
- Skeleton sanity. After pruning, spur count ≈ 0, and at 4× zoom the skeleton overlay runs mid-mask along the whole crack.
When all six pass, the width, length and area numbers are ready to feed the accept/reject layer — turning line results into decisions shows that decision layer wired up on a running line.
To size the optics for your own part: set the field from the pixel budget, pick focal length from the formula above, then browse the machine vision lenses and area scan cameras pages or start at the system configurator. Send us the field size and smallest crack and we will quote a matched set.
Questions
Does a rolling shutter corrupt crack width on a moving part?
Yes. A rolling-shutter sensor reads rows sequentially, so a part moving during exposure skews vertical edges and can bias both width and length by several pixels at belt speed. Keep the part stationary during exposure, strobe the light to freeze motion, or use a global-shutter camera for anything faster than a paused indexing station.
How much does the mm-per-pixel scale change across the field of view?
With a flat part and a corrected lens it barely changes: lens distortion is the main term, so a lens specified under 0.3% distortion keeps the local scale within 0.3% of the centre value without any correction. If your lens is worse than that, calibrate a per-position scale from a grid target instead of one centre number.
Can I report in pixels and skip the calibration target?
Only for relative comparisons. Pixel numbers let you track growth between images taken on the same set-up, but they cannot be compared with a gauge, a drawing tolerance or another line. A ruler lying in the part plane gives a scale good to a few percent; a certified target at part height is the defensible version.
Do the measurements change if a deep-learning model made the mask?
No. The skeleton and area maths run on any binary mask, whether it came from morphological thresholds, multiscale gradients or a trained segmentation model — recent concrete-crack segmentation models estimate width and length per pixel with the same ideas. Mask quality is what transfers: validate the mask on cracks of known width before trusting the outputs.
What accuracy should I promise for image-based crack width?
With 3-5 pixels across the crack, a half-maximum threshold and a same-day scale, ±0.5 pixels per edge is a realistic bound: ±0.03 mm on width at 0.03 mm per pixel, counting both edges at worst case. Telecentric optics, subpixel edge fitting and stable lighting tighten it; coarse pixels and drifting thresholds widen it fast.


