A vug is a hole. On a borehole image log it shows up as a dark, low-resistivity blob where the rock has dissolved away — a pore large enough to matter for storage and flow, scattered through a carbonate at no fixed spacing and no fixed size. A petrophysicist quantifies these by eye in the interpretation software, measuring blobs across hundreds of metres of imagery from two different microresistivity imaging tools, and the resulting vug-porosity log feeds straight into the reservoir model. It is exactly the kind of slow, judgement-heavy interpretation that invites automation — the question is what kind. In an engagement with a mid-sized Middle East carbonate operator we partnered with, the answer was deliberately not a deep network. It was a classical computer-vision detector built from eight interpretable parameters, and that interpretability is the whole point. This piece walks through all eight, what each physically controls, and why a parameter you can read beats a black box for a task whose entire job is quality control.
Why classical CV, not a black box
Having just shipped a Detection Transformer for fractures on the same wells, the temptation was to throw a segmentation network at vugs too. We resisted it, for a reason specific to the deliverable. The output here is not a detection a geologist will sanity-check — it is a porosity log that goes into the static model. When a vug-porosity curve looks wrong, the petrophysicist has to be able to ask why: which blob was counted, which was rejected, on what criterion. A semantic-segmentation mask gives you a number and a shrug; a pipeline whose every decision is a named, tunable threshold gives you an audit trail.
There is also a hard data constraint. The prior-art baseline — a path-morphology approach in the Li et al. 2019 lineage — was both slow, on the order of five minutes per metre of log, and prone to false positives a human then had to clean up. We wanted something faster and legible: an unsupervised pipeline with no training labels to overfit, running at roughly 15 seconds per metre, where every false-positive filter is a knob an operator turns per well rather than a weight buried in a checkpoint. The rest of this article is the eight constants that result.
Parameter 1 — block size: the neighbourhood of "local"
Adaptive thresholding begins with a question: local relative to what? Global Otsu fails here because a vug that is dark against bright dolomite in one zone may be the same grey value as ordinary matrix two metres up the well. The threshold has to be computed per-neighbourhood, and the block size is the side length of that neighbourhood.
This is the first place interpretability earns its keep, because the block size has physical units. On these logs a single pixel of the binary wireline log file maps to about 3 cm of borehole — which already imposes a floor of roughly ±3 cm of inherent depth uncertainty on anything the pipeline reports. A block of 11 pixels covers 5.87 cm² of borehole wall; 31 pixels covers 46.58 cm²; 51 pixels covers 126.08 cm². We swept 11, 21, 31, 41, and 51 and settled on 31. The reasoning is geometric: 46.58 cm² is large enough to contain a whole vug plus a collar of matrix to threshold it against, and small enough that the "local" baseline does not drift across a zone boundary. A heterogeneous well can be re-tuned — one validation well used a block size of 51 — but the operator knows exactly what they are changing: the physical area over which "dark" is defined.
Parameter 2 — the C constant: how far below the mean is a vug
Adaptive thresholding subtracts a constant C from the local mean before deciding what counts as foreground. Set C too low and matrix texture leaks in as spurious vugs; too high and shallow vugs vanish. We swept C from −2 to +2 and found the optimum at the local patch mean itself (equivalently, a small offset near −1). In plain terms: a pixel is a vug candidate when it is darker than the average of its 31×31 neighbourhood. That is a sentence a petrophysicist can argue with — and being able to argue with it is the feature, not a limitation.
Parameters 3 & 4 — k modes and delta-m: enhancing local variation before you threshold
Before any thresholding, the pipeline enhances local variation by top-k mode subtraction. The histogram of a 0–255-scaled image patch has a long tail caused precisely by the vugs — the dark blobs in water-based mud — so rather than fit a Gaussian and call the tail outliers, we extract the k most frequent intensity modes and build a stack of mode-subtracted images. Two parameters govern this: k = 5 (the top five modes) and delta-m = 5, the minimum intensity-level separation between the modes we keep.
Both numbers come from an ablation, not a guess. Consecutive modes — delta-m of 1 — produce more than 90% duplicate contours, because near-identical intensities trace near-identical blobs; spacing them at delta-m = 5 yields modes that pick out genuinely distinct features. And k = 5 is where the marginal mode stops paying for itself: the first mode carries a frequency around 4,700 and the fifth around 1,700, after which you are subtracting noise. Five mode-subtracted images, each then Gaussian-modulated and adaptively thresholded, give the contour stage five complementary views of the same metre of rock.
Parameter 5 — circularity: the one geometric gate
After contour extraction — done with the standard Suzuki–Abe border-following algorithm — the pipeline has a population of candidate blobs, and most are not vugs. The single most important geometric filter is circularity, the ratio that is 1.0 for a perfect circle and falls toward 0 for an elongated streak. Dissolution vugs are roughly equant; the artefacts you most want to reject — wellbore-parallel scratches, residual fracture traces, drilling-induced linears — are elongated. We keep contours with circularity in 0.3 to 1.0 and discard the rest.
That gate is not arbitrary: across the validated wells the real vug population sits at circularity 0.28 to 0.85, peaking between 0.45 and 0.7 — semi-circular blobs dominate, as you would expect from coalesced dissolution. The gate sits just below the bottom of that distribution, so it rejects linear artefacts without clipping the genuinely irregular vugs. The instrument below makes the gate tactile: drag it along the circularity axis and watch elongated fractures fall out grey while true vugs stay teal — including several the manual interpreter missed.
Parameter 6 — IoU and the centroid gate: one vug, counted once
Five mode-subtracted images mean the same physical vug is often traced five times. Sum those and your porosity is wildly inflated, so the pipeline aggregates duplicate contours across the stack with two parameters. The first is an IoU threshold of 0.2 (20%): two contours whose intersection-over-union exceeds 20% are treated as the same vug and merged. The second is a centroid-difference gate, tau = 5 pixels: candidates whose centres sit within tau of each other are also collapsed. We tested tau at 0, 1, 3, 5, 8, and 12; below 5 the merge is too timid and duplicates survive, above 5 it starts fusing genuinely adjacent vugs into one. Five pixels — about 15 cm on this log — is the elbow where duplicate removal stabilises, each tightening step removing progressively fewer contours.
This is the deduplication a non-maximum-suppression step does in a learned detector — but here it is two readable numbers instead of a heuristic with its own failure modes, and a petrophysicist can see why two blobs were declared the same vug.
Parameters 7 & 8 — Laplacian and mean-based filtering: killing the last false positives
The final two parameters exist to remove the false positives that survive geometry. The Laplacian filter (threshold 0.25, swept across 0.05–0.75, with a 10% bounding-box expansion so it reads the blob's rim) measures local image sharpness: a true vug is a smooth, low-variance dark region, whereas a sharp-edged artefact lights up the Laplacian and gets cut. The mean-based filter (threshold 0.8, swept across 0.1–2.0, evaluated over an enlarged circle of radius 2R) checks that the candidate is genuinely darker than its surroundings — a real vug must hold a meaningful intensity contrast against the matrix ring around it.
Two filters, two numbers, two named physical claims: a vug is smooth and a vug is dark against its neighbourhood. When a heterogeneous well throws a new class of false positive, the operator adjusts one of these two thresholds and can state, in one sentence, what changed — one re-tuned well used a Laplacian of 0.15 and a mean-based threshold of 0.4 for exactly this reason.
The payoff: a porosity log you can interrogate
Those eight constants — block size 31, C = patch mean, k = 5 modes, delta-m = 5, circularity 0.3–1.0, IoU 0.2, Laplacian 0.25, mean-based 0.8, with the centroid gate tau = 5 stitching them together — turn a metre of borehole image into individually counted vugs, then into a vug-percentage curve computed every 0.1 m. Validated on three wells in the operator's carbonate play — a vertical well and a second vertical well logged with high-resolution borehole image logs, and a horizontal well logged with a compact microresistivity tool — against the expert's interpretation-software ground truth, the detector's vug areas track the real population (predominantly 1–6 cm², range spanning 1–12 cm²) at a mean absolute error of 1.21 cm² against the expert's measured areas. In several intervals it flagged dissolution porosity the manual interpreter had missed entirely.
That last result is the argument for interpretability stated as an outcome. The detector did not just approximate the human — at times it outperformed the human, and because every gate is named, the petrophysicist could open each newly flagged blob, confirm it cleared the circularity gate, survived the Laplacian and mean-based filters, and was not a duplicate, and accept it on the evidence. A black box that found the same vugs would have been less useful, because it could not show its work. For a number that goes into a reservoir model, showing your work is not a nicety — it is the deliverable.
Takeaways for the practitioner
The lesson is not "classical CV beats deep learning." On the fracture problem next door, set prediction with a transformer was unambiguously the right tool. The lesson is to match the architecture to the deliverable. When the output is a QC artefact that a domain expert must trust, sign off on, and feed downstream, a pipeline of eight legible parameters — each with physical units and a one-sentence justification — buys you something a learned model cannot: the ability to be argued with, audited, and re-tuned per well without retraining. Across operators in the Middle East and the United States, the pattern holds — the right amount of "AI" is sometimes eight well-chosen constants.
Key takeaways
- A vug detector for carbonate image logs can be built as a fully interpretable classical-CV pipeline governed by eight parameters — block size, the C constant, top-k modes, delta-m, circularity, IoU, Laplacian and mean-based thresholds — plus a centroid gate, with no training labels to overfit.
- Every parameter carries physical meaning: block size 31 px covers 46.58 cm² of borehole wall (1 wireline-log-file pixel ≈ 3 cm), C = the local patch mean, and the circularity gate of 0.3–1.0 sits just below the real vug distribution (0.28–0.85, peaking 0.45–0.7) so it rejects linear artefacts without clipping true vugs.
- Top-k mode subtraction (k = 5, delta-m = 5) enhances local variation before Gaussian-modulated adaptive thresholding; consecutive modes (delta-m = 1) produce >90% duplicate contours, which is why the modes must be spaced.
- Deduplication across the five mode-subtracted views uses an IoU threshold of 0.2 and a centroid gate of tau = 5 px — readable replacements for NMS — while Laplacian (0.25) and mean-based (0.8) filters encode two named physical claims: a vug is smooth and a vug is dark against its surroundings.
- Validated on three Middle East carbonate wells against the expert's interpretation-software ground truth, the detector tracks vug areas of 1–6 cm² (range 1–12 cm²) at a mean absolute error of 1.21 cm², runs at ~15 s/m versus ~5 min/m for the path-morphology baseline, and at times found vugs the expert missed — interpretability is what let the petrophysicist accept those on the evidence.
References
[1] Suzuki, S., and Abe, K. Topological Structural Analysis of Digitized Binary Images by Border Following. Computer Vision, Graphics, and Image Processing (1985). The border-following algorithm used for contour extraction in the pipeline.
[2] Li, X., et al. Automatic characterization of vugs from borehole image logs via path-opening morphology (2019). The path-morphology lineage this detector was built to replace on grounds of speed and false-positive rate.