Fine crack tracing toolkit
Turns a crack mask into measured centrelines: length, width at every point, branches, and breaks bridged.
My partBuilt from scratch
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.

Step by step
- 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. 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
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.

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
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 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
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.

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%. 
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