Mudlog lithology extraction
Reads the rock column off scanned well logs
Built with a team at HackTheBurgh 13.
- Hackathon project · HackTheBurgh 13
- Computer vision
- Python
- OpenCV
- NumPy
- RapidOCR
Overview
A mudlog is the printed record of a well: a depth strip, a column of rock types drawn as hatch patterns, and a legend explaining each pattern. This pipeline reads scanned and digital mudlogs and returns the column as a table: each interval's top and base in pixels and in depth, a cluster id, and a name from the log's own legend.
It is classical computer vision. Nothing is trained for the task, nothing leaves the machine, and the only model is an off-the-shelf OCR engine. Across 52 documents it averaged 9.9 seconds each on a CPU. It won at HackTheBurgh 13.
How it works
From page to rows
Each page splits into three crops that are read separately and joined at the end. Of the 52 documents, 43 took the palette path and 9, all black-and-white, the texture path.
01 Crop
Each page is cut into three crops: the legend, the lithology column and the depth strip. The boxes are supplied, or found by an optional step that matches the page's layout against annotated pages.02 Legend
OCR reads the legend's labels. For each label the swatch is searched for to its left, then above, never past halfway to the next label. Drilling symbols and accessory words are dropped.03 Column
Colour pages take the palette path: pixels are matched to the legend's fill colours. Black-and-white pages take the texture path: ink blobs are sorted into dots, dashes, ticks and lines. This page is in colour.04 Depth
Up to 48 labels in the depth strip are read by OCR and fitted to a line that maps any pixel row to a depth (Fig. 03).05 Join
Each interval takes its name from the legend and its depths from the fit, and becomes one CSV row: top and bottom row, cluster, lithology, top and base depth.
From rows to intervals
The column is read one pixel row at a time and the rows disagree, so an exact Viterbi pass with a penalty for changing label turns them into intervals without erasing thin beds. Where legend swatches share a fill colour, each swatch is also slid over the column at every offset to decide which one it is.
01 Vote
Each pixel row of the column votes for the legend colour most of its pixels match; ink and grid lines carry no vote. Depth runs left to right here. Read row by row, the votes are noisy.02 Viterbi
One exact pass finds the cheapest labelling of the whole column. A row costs the share of its pixels that disagree with its label, at most 1, and every change of label costs 1.5.03 Penalty
A stray row would save at most 1 but add two changes (3.0), so it is overruled. Clean runs of 2–6 rows in one legend colour cost three times as much to overrule, so a thin bed survives.04 Intervals
Runs of one label become intervals with boundaries. White runs are split again by texture, and a blank run is marked as no data rather than given a name.
From labels to depth
Depth comes from the labels printed beside the log, most of them abbreviated, so the fit has to work out what each one means before it can trust it.
01 Read
Text blobs in the depth strip are found, and up to 48 of them, spread down the log, are read by OCR, with rotation voted from blob shape. A few labels are full depths; most are abbreviated.02 Fit full labels
Full labels are fitted first, by RANSAC: the line that agrees with the most labels wins, so a number that is not a depth tick, such as an annotation, falls outside it.03 Expand
Each abbreviated label is expanded to the value closest to that line: the 40 between 3900 and 4000 becomes 3940, not 4040.04 Refit
The line is refitted with every label and checked against the depth range in the file name where there is one. All 52 documents got a fit; all 27 with a range in the name agreed with it.
What this doesn't cover
- The real-page check is 16 short windows labelled by the team that built the pipeline, from the raw crop and legend, before seeing any output. Several hold only a handful of boundaries. Row accuracy on them was 0.952; that is a sanity check, not an independent benchmark.
- The synthetic benchmark tiles each document's own legend swatches into random columns, so its answers are exact (boundary F1 0.889, row accuracy 0.902), but it cannot reproduce scans whose legend is drawn at a different density from the column. Beds of 2–4 rows were recovered 58% of the time.
- Swatches that share a fill colour and an almost identical hatch, such as fine and medium sand, cannot be told apart reliably. The output gives a confidence and an alternative name for those rather than hiding it.
- The logs are third-party documents, so nothing from them is shown here. Every figure on this page is a schematic drawing.