Skip to main content

Blog

Erasing the Grid: Graticule Removal as a Domain-Knowledge Preprocessing Step

A scanned well log carries two kinds of dark ink: the logging curve, which is signal, and the printed graticule of track borders and depth grid lines, which is furniture. A naive segmenter cannot tell them apart, because at the pixel level a grid line and a curve are the same thing, a dark stroke on light paper. The document-image literature has spent decades separating ruling lines from content, from morphological line removal to Hough-based detection to learned text and graphics separation. This post surveys that lineage, credits it, and then makes one engineering claim that is ours: because we know exactly what a well log is supposed to look like, we can strip the periodic grid before VeerNet ever sees a pixel, and that single prior turns a hard segmentation problem into a merely difficult one.

The EarthScan Teamby The EarthScan Team12 min read
EarthScan insight

Hold a scanned paper well log up close and ask a simple question: which of these dark marks is the data? The honest answer, at the level a computer first sees the image, is that you cannot tell. The logging curve threading down the track is a dark stroke on light paper. The printed depth grid lines are dark strokes on light paper. The two vertical track borders that box the curve in are dark strokes on light paper. A pixel does not carry a label that says I am signal or I am furniture; it carries a gray value, and dark is dark. This is the whole difficulty of pulling curves off raster logs, compressed into one observation, and it is the reason the first model you train will confidently trace the grid.

The fix is not a cleverer model. It is a piece of knowledge the model does not have and we do: a well log has a known, regular structure. The grid is periodic. The track borders sit at fixed margins. The curve is the one stroke that wanders. If you can encode that prior as a preprocessing step and strip the periodic ink before the network ever sees a pixel, you hand the segmenter a far easier problem, one where almost every dark pixel that remains really is the curve. None of the machinery for doing this is new. Separating ruling lines from content is one of the oldest chores in document image analysis, and the field has a deep, well-credited toolbox for it. What is ours is the decision to treat graticule removal as a domain-knowledge step specific to logs, and to measure what that decision buys.

Why a global threshold cannot save you

The instinct, when you want the dark ink out of a grayscale scan, is to threshold. Pick a gray value, call everything darker than it foreground, everything lighter background, and move on. Otsu's method automates the choice by finding the threshold that best separates the two modes of the gray histogram [1], and for a clean scan it does a fine job of telling paper from ink. The trouble is that it tells paper from ink, not curve from grid. Both the logging trace and the printed graticule fall on the ink side of any threshold you pick, because both are ink. Thresholding solves the problem you do not have, the page-versus-mark problem, and leaves the problem you do have, the curve-versus-furniture problem, exactly where it was.

Worse, the real scans are not clean. Decades-old paper logs arrive faded, stained, photocopied, and bled through from the reverse side, so a single global threshold over-thresholds the dark regions and under-thresholds the faded ones. Adaptive binarization, which sets a local threshold per neighbourhood to cope with uneven illumination and degradation, is the right tool for that part, and Gatos and colleagues give the canonical recipe for noisy historical documents [5]. But adaptive binarization makes the picture cleaner, not more separable. A perfectly binarized scan still has the grid and the curve sitting in the same foreground class. So the first lesson, which the field learned long before us, is that no amount of threshold tuning separates two things that are both ink. You need a step that knows about shape, not just darkness.

The classical toolbox for ruling lines

Document image analysis figured out long ago that ruling lines have a property content does not: they are long, straight, and regular. That property is exactly what you exploit to remove them, and there are two classical families for doing it.

The first is morphological. Mathematical morphology lets you probe an image with a structuring element of a chosen shape, and an opening with a long, thin horizontal structuring element survives only where a long horizontal run of ink exists, which is to say on the horizontal grid lines and nowhere else. Subtract that result from the binarized image and the horizontal rulings vanish while the curve, which is never a long straight horizontal run, is left almost untouched. Soille's treatment is the standard reference for the operation and its properties [3]. Rotate the structuring element to vertical and you catch the two track borders. The appeal of the morphological route is that it is cheap, deterministic, and makes a guarantee in the shape language the problem is actually stated in: erase what is line-shaped, keep what is not.

The second family is voting-based. The Hough transform maps each foreground pixel to the set of lines that could pass through it and accumulates votes in a parameter space, so a long straight ruling, traversed by many collinear pixels, becomes a sharp peak [2]. Detect the peaks, reconstruct the lines, and erase them. The Hough route is more tolerant of small gaps and skew than a rigid morphological opening, because a slightly broken or tilted grid line still votes for roughly the same peak, but it is heavier to compute and needs care so that the long, smooth stretches of the logging curve do not themselves vote up a spurious line. Both families predate deep learning by decades, both are documented to exhaustion, and both work. We did not invent either, and we lean on the morphological one because the synthetic grid we generate is regular enough that an opening is the simplest thing that is correct.

Where this sits in the larger separation problem

Stripping the graticule is a narrow instance of a much broader task the literature calls text and graphics separation, or more generally the separation of distinct ink layers that happen to share a page. Zheng and colleagues framed an early version of it for noisy documents, distinguishing machine-printed marks from handwriting from noise, and the framing carries over cleanly [4]: a scanned log is a document with at least two ink layers, the machine-printed grid and the recorded curve, and the job is to keep one layer and discard the other. Reading our problem as a special, easy case of that general one is useful, because it tells you what to expect. The general separation problem is hard precisely when the layers are statistically similar. The reason ours is tractable is that one layer, the grid, is rigidly periodic and the other, the curve, is not, and periodicity is a strong, exploitable prior. We are not solving general text and graphics separation. We are solving the one case where the structure of the graphics is known in advance.

That framing also makes clear what graticule removal is not. It is not denoising, which removes random speckle without caring about shape. It is not binarization, which is upstream of it. It is a content-aware deletion of a specific, predictable structure, and the only reason we can do it safely is that we know, before we look at any particular scan, what the structure is going to be. The prior is the whole asset.

What the prior buys VeerNet

Here is the part that is ours: the engineering decision, and what it does to the numbers. VeerNet, our raster well-log digitiser, learns to segment the curve from a single grayscale channel. A scanned log is one input channel, a few hundred pixels tall, and the synthetic logs we train on span a 480 to 640 pixel height range. The defining feature of the input is its imbalance. A logging curve is a one-to-three-pixel-wide ink trace, so across the whole frame the foreground is a tiny minority. At our operating point the curve is roughly three percent of the pixels, which means the background is about ninety-seven percent, and that single ratio is what every downstream loss choice has to wrestle with.

Now watch what the graticule does to that ratio if you leave it in. The grid is also dark ink, so a naive foreground detector counts every grid pixel as curve. The apparent foreground share climbs above its true three percent, and worse, the extra pixels are not curve at all, they are printed furniture in long straight lines that a thin-structure segmenter is biased to latch onto. You have taken a problem that was hard because the signal is rare and made it hard for a second, independent reason: the rare signal is now buried in a confuser that looks exactly like it. The instrument below lets you feel that directly.

GRID REMOVAL · WHAT THE SEGMENTER SHOULD NEVER SEE9.2%of the frame reads as foregroundGRID INK CONTAMINATES THE FOREGROUNDThe printed graticule is dark ink the model would mistake for curveDrag to set grid density on the page; toggle the filter to strip the periodic mask before the segmenter sees a pixel.1 channel · 480 to 640 px tallcurve tracegraticule inkapparent foreground-pixel sharewhat a threshold counts as ink, curve plus printed grid3% · true curve0%18%grid adds 6.2 points of false foreground a threshold would chasegrid onraw scanned pagesuppressstrip periodic inkdomain prior:a log has a known gridsparse grid4 linesdense grid24 lines12 depth grid lines on the page · drag to change densitysourced: 1 grayscale input channel; synthetic log height 480 to 640 px; about 97 percent background to 3 percent curve at the operating point ·grid-ink fraction is illustrative geometry that scales with line count; the 3 percent curve floor and the suppressed share are the sourced anchors
A scanned well log is a single grayscale channel a few hundred pixels tall (the synthetic corpus spans a 480 to 640 pixel height range), and the only signal worth learning, the thin ink trace of the logging curve, is roughly 3 percent of the pixels, so the background share is about 97 percent. The printed graticule, the periodic track borders and depth grid lines, is also dark ink, so a naive thresholding segmenter counts those grid pixels as foreground and inflates the apparent curve share far above the true 3 percent. Drag the slider to set how many depth grid lines the page carries across its 480 to 640 pixel height, and toggle the suppression filter: grid on shows the inflated, contaminated foreground a threshold would chase; suppress strips the periodic mask and returns the foreground to the 3 percent the curve actually occupies. The 1 input channel, the 480 to 640 pixel height range, and the 97 percent background to 3 percent foreground split are sourced from the engagement archive; the grid-ink fraction is illustrative geometry that scales with the chosen line count, and the suppressed share returns to the sourced 3 percent floor.

Slide the grid denser and the apparent foreground share inflates, every added depth line a fresh band of false positives the model would chase. Toggle the suppression filter on and the periodic ink disappears, the apparent foreground collapses back to the true three percent, and what remains in the foreground class is the curve and essentially nothing else. That collapse is the entire value of the preprocessing step stated as one number. Before suppression, the foreground class is a mixture of signal and a structured confuser. After suppression, the foreground class is the signal. The segmenter that trains on the second image is solving a cleaner problem than the segmenter that trains on the first, even though it is the same network with the same loss.

The reason this matters for a learned model specifically, and not just for a classical pipeline, is that the network's capacity is finite and its training signal is dominated by the majority. A segmentation backbone like U-Net recovers thin structures through its skip connections [6], which is exactly why it is a good fit for one-pixel curves, but that same sensitivity to thin structure is what makes it eager to trace a one-pixel grid line. If you do not remove the grid, you spend model capacity and training signal teaching the network to suppress a confuser you could have deleted for free with an opening. Strip it first, and every gradient the network sees is about the curve.

The discipline this points to

The reflex worth taking from a logging-specific chore is broader than logs. When your input has a known, regular structure that is not the thing you want to learn, the cheapest place to remove it is before the model, not inside it. A learned segmenter can, in principle, learn to ignore the graticule, the same way it could learn any invariance given enough labels and capacity. But you would be paying for that with annotation budget and model capacity to relearn a fact you already know with certainty: that a well log has a grid, and where the grid lives. The classical toolbox, morphology and Hough and adaptive binarization, exists precisely to encode that kind of certain, structural knowledge cheaply and deterministically, and the modern instinct to throw everything into the network should not blind anyone to how much it gives away when a deterministic prior is available. We strip the grid before VeerNet sees a pixel not because we cannot teach it to ignore the grid, but because teaching it would be paying twice for something we already know for free.

Key takeaways

  1. At the pixel level a printed graticule and a logging curve are the same thing, dark ink on light paper, so no global threshold can separate them. Otsu's method tells paper from ink, not curve from grid, and adaptive binarization makes the scan cleaner without making it more separable.
  2. The classical document-image toolbox already solves ruling-line removal by exploiting shape, not darkness: a morphological opening with a long structuring element erases line-shaped ink while sparing the wandering curve, and the Hough transform votes long straight rulings into peaks you can detect and delete. We credit both and use the morphological route on our regular synthetic grid.
  3. Graticule removal is a narrow, easy instance of text-and-graphics separation: it is tractable precisely because one ink layer (the grid) is rigidly periodic and the other (the curve) is not. Periodicity is the exploitable prior, and it is known in advance of any particular scan.
  4. The engineering payoff for VeerNet, our raster-log digitiser, is concrete: the input is 1 grayscale channel, 480 to 640 pixels tall, with the curve at roughly 3 percent of pixels and the background near 97 percent. Leaving the grid in inflates the apparent foreground above 3 percent and contaminates it with a structured confuser a thin-structure segmenter is biased to trace.
  5. Remove known, regular structure before the model rather than inside it. A U-Net could learn to ignore the grid through its thin-structure-sensitive skip connections, but that spends annotation budget and capacity relearning a fact a deterministic opening encodes for free. Strip the grid first and every gradient the network sees is about the curve.

References

[1] Otsu, N. A Threshold Selection Method from Gray-Level Histograms. IEEE Transactions on Systems, Man, and Cybernetics, 9(1), 62 to 66 (1979). The histogram-based global threshold a naive ink detector starts from, and the reason it cannot separate grid from curve. https://ieeexplore.ieee.org/document/4310076

[2] Duda, R. O., and Hart, P. E. Use of the Hough Transformation to Detect Lines and Curves in Pictures. Communications of the ACM, 15(1), 11 to 15 (1972). The voting scheme that turns long straight rulings into peaks in a parameter space, the classical way to find a graticule. https://dl.acm.org/doi/10.1145/361237.361242

[3] Soille, P. Morphological Image Analysis: Principles and Applications, 2nd ed. Springer (2003). The opening-with-a-long-structuring-element recipe that erases thin straight lines while preserving everything that is not line-shaped. https://link.springer.com/book/10.1007/978-3-662-05088-0

[4] Zheng, Y., Li, H., and Doermann, D. Machine Printed Text and Handwriting Identification in Noisy Document Images. IEEE Transactions on Pattern Analysis and Machine Intelligence, 26(3), 337 to 353 (2004). An early statement of the text-and-graphics separation problem this preprocessing step is a special case of. https://ieeexplore.ieee.org/document/1262332

[5] Gatos, B., Pratikakis, I., and Perantonis, S. J. Adaptive Degraded Document Image Binarization. Pattern Recognition, 39(3), 317 to 327 (2006). Local adaptive binarization for faded, stained, bleed-through scans, the realistic input a global threshold fails on. https://www.sciencedirect.com/science/article/abs/pii/S0031320305003821

[6] Ronneberger, O., Fischer, P., and Brox, T. U-Net: Convolutional Networks for Biomedical Image Segmentation. MICCAI (2015). The encoder-decoder segmentation backbone whose skip connections recover the thin structures a downsampling network would otherwise lose. https://arxiv.org/abs/1505.04597

Go to Top

© 2026 Copyright. Earthscan