Skip to content

© 2026 Rami Kronbi · Beirut, Lebanon

Back
Vision · inspection

Fine crack tracing toolkit

Turns a crack mask into measured centrelines: length, width at every point, branches, and breaks bridged.

My partBuilt from scratch

The tracer’s own output on a wall from the Concrete Crack Segmentation Dataset (Özgenel, 2019, CC BY 4.0), played in order: the skeleton, its ends and junctions, then the smoothed centreline coloured by width.

In short

An installable Python package and CLI that turns a crack segmentation mask into measured centrelines: each crack’s length, its width at every point, its branches, and the breaks the mask left in it.

What it is
A Python package and command-line tool that turns a crack segmentation mask into measured centrelines: where each crack runs, how long it is, how wide it is at every point, where it branches and where the mask broke it.
Why it matters
A segmentation mask names the crack pixels, but an inspection needs a length, a width it can compare with a limit, the branches, and a line it can put on a drawing or compare with the last survey.
My part
I built it from scratch for crack and damage extraction: not just a segmentation mask, but measurements. Version 1.0 rebuilds it around the skeleton approach that worked in practice, with a synthetic benchmark to check every step. I maintain the package, its command-line interface and its documentation.
A cracked concrete wall with its crack network traced as lines coloured from mint to magenta by width, white rings at the junctions.
A wall from the Concrete Crack Segmentation Dataset (Özgenel, 2019, CC BY 4.0), traced from its hand-drawn mask. The colour is the width across the crack at that point, mint for thin and magenta for wide; rings mark junctions.

Step by step

  1. 1

    Thin

    Any mask goes in: binary, colour, RGBA or a probability map. Each crack is thinned to a one-pixel skeleton and read as a graph; side branches shorter than 2.5 half-widths of the crack are cut as spurs from ragged edges.

    The repository’s test mask traced twice. Left: purple corner points linked around the outline of each crack. Right: one line down the middle of each crack, coloured by width, with junction rings and a dashed join across a break.
    The repository’s test mask. The first version linked Shi-Tomasi corners with a spanning tree and traced each crack’s outline; version 1.0 follows the centreline, finds the branches, bridges the break between the top two pieces, and colours the line by width.
  2. 2

    Join

    Pieces that a segmentation break split apart are joined when their ends face each other, within three crack widths. Bridged stretches stay flagged in every output. Free ends are carried out to the tips of the mask.

    Four panels of the same wall crop: the mask, its skeleton with short spurs in red, the graph after pruning and bridging with the trunk in white and branches in colour, and the finished line on the photo.
    One crop, step by step: the mask, its raw skeleton with the spurs that get cut in red, the graph split into a trunk and branches, and the finished line coloured by width.
  3. 3

    Measure

    Each crack becomes a trunk and its branches. The width across the crack is found at every point to sub-pixel, and a pixel size turns lengths and widths into millimetres, with the length of crack in each width class.

    Three cracked walls traced and labelled with each crack’s length and maximum width in pixels.
    Three more walls from the dataset. Across all 458 of its masks the tracer found 1,008 cracks, branches in 416 images and 126 breaks to bridge, in a median 0.63 s per 8 to 12 megapixel mask on one laptop core.
  4. 4

    Score

    A generator draws synthetic cracks with exact centrelines and widths, then damages their masks; a benchmark scores every tracer on them, the first version included. An eval command scores any trace against reference lines.

    Bar charts of centreline F1 and length error for four tracers on clean, ragged, broken and realistic synthetic masks.
    On 100 synthetic images with exact ground truth, version 1.0 scores an F1 of 0.97 within 3 px, sits 0.52 px from the true centreline, and gets each image’s total length within 1.9% on average. The first version scores 0.20 and misses most of each crack; a plain skeleton overstates ragged cracks by 21%.
    Line charts of distance from the true centreline and length error against crack width from 1.5 to 32 pixels for four tracers.
    Single ragged cracks from 1.5 to 32 px wide. The corner tracers drift further from the centre as cracks widen; version 1.0 stays within about a pixel and a half and within 2.5% of the true length.
For engineersHow it is built, its limits, and its keywords.

How it works

It thins each crack to a skeleton and reads it as a graph of ends and junctions, cuts the spurs ragged mask edges leave, joins pieces whose ends face each other across a break, and splits each crack into a trunk and branches. Each line is smoothed in proportion to the crack’s width, centred, and measured across the crack at every point to a fraction of a pixel. Where a skeleton cannot describe a crack, Shi-Tomasi corners walked onto the centreline and linked by a minimum spanning tree take over.

Limits

  • It measures the mask it is given, so a width is only as good as the segmentation behind it.
  • Widths are in pixels until a pixel size is given, and a pixel size assumes the camera faces the surface square on; it does not correct perspective.
  • Bridging guesses that two facing ends are one crack. Bridged stretches stay flagged so they can be counted separately or left out.
  • The toolkit begins after segmentation and is not a crack detector.
  • The benchmark is synthetic. On real masks, the check is how steady the trace stays when the mask is damaged, not how close it is to a measured crack.

Keywords

  • crack tracing
  • crack width measurement
  • skeletonization
  • segmentation post-processing
  • infrastructure inspection

Read the write-up →