Skip to content

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.

Fig. 01 · Page to rows
From one mudlog page to one interval tableA schematic page is cut into three crops: legend, lithology column and depth strip. OCR reads the legend's labels and finds each swatch. A router sends the column down the palette path for colour pages or the texture path for black-and-white pages. The depth strip's labels are read and fitted to a line. The names, intervals and depths join as one CSV row per interval.LEGENDDEPTHCOL.LEGENDOCR,swatchesROUTEcolour orb/wPATHpalette /textureOCR≤48labelsFITRANSACINTERVAL TABLEone row per interval:name · rows · depths
  1. 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.
  2. 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.
  3. 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.
  4. 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).
  5. 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.

Fig. 02 · Rows to intervals
Per-row votes resolved into intervals by an exact Viterbi passA strip of pixel rows, each voting for sandstone, shale or limestone, with a few single rows voting wrongly. A path through three lanes picks the cheapest labelling, where every change of label costs a penalty. Single-row votes are overruled; a clean three-row limestone bed is kept. The result is a strip of clean intervals with boundaries.rows, top → bottomvotesSandstoneShaleLimestonerow cost ≤ 1each change of label +1.51 row: overruled3 clean rows: keptintervalsSandstoneShaleShale
  1. 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.
  2. 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.
  3. 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.
  4. 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.

Fig. 03 · Rows to depth
Depth labels read by OCR and fitted to a lineA depth strip with labels 3900, 20, 40, 60, 80, 4000 and so on, and an annotation reading PC 4065. Seven labels and the annotation are read. Full labels are fitted first by RANSAC, which leaves the annotation out. Abbreviated labels are expanded to the value closest to the line, so 40 becomes 3940. The line is refitted with every label.390040004100depthrow →read:40602060not atick3940a · row + b
  1. 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.
  2. 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.
  3. 03 Expand

    Each abbreviated label is expanded to the value closest to that line: the 40 between 3900 and 4000 becomes 3940, not 4040.
  4. 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.