Topology-Guided Transfer of Grain-Boundary Segmentation Across Alloys

A network trained to trace grain boundaries in one metal's micrographs usually does worse on a different alloy. The etchant, the crystal structure and the phase contrast all change, so the faint lines separating grains look different. No published work has measured how large this drop is. One property does survive the change of material, though: in a single-phase polycrystal, grain boundaries tile the image into closed cells. Boundaries do not stop in mid-grain, and every grain is a region fully enclosed by boundary. The number of cells varies enormously between alloys and cooling histories. The fact that the image is partitioned into closed cells does not vary.

We propose to use that closed-cell property as a training signal on unlabeled micrographs of a new alloy. The method adapts a boundary segmenter to the new material without new annotations. We also build the first leave-one-alloy-out benchmark that measures how much material specificity costs in image space. The core idea in two sentences: existing topology losses tell a network how many holes and components the answer should have, which is wrong for materials, where grain count is exactly what we want to measure. Instead, we tell the network that every candidate grain should be either clearly enclosed or clearly absent, never half-closed, and that requirement holds for every alloy.

Core Claim

Persistent homology tracks connected regions and loops of a thresholded image as the threshold sweeps. Each feature has a "persistence", meaning how long it survives. A Persistent Homology-Based Topological Loss for CNN-Based Multiclass Segmentation of CMR used this to push cardiac segmentations toward known Betti numbers, the counts of components and holes. With CubicalRipser, per-slice computation fell from about 6 minutes to 7 seconds, and 2D topological success rose from 85.3% to 98.7%. That paper supplies our computational method. It also constrains our design, because its authors identify the fixed-prior assumption as its main limitation, and a fixed grain count is meaningless across alloys.

We replace the count prior with a "decisiveness" prior. Let $q$ be the predicted grain-interior probability map, which is one minus the boundary probability. Let $\{(b_i, d_i)\}$ be the birth and death thresholds of the 0-dimensional features, the separate interior regions, in the superlevel filtration of $q$. Let $p_i = b_i - d_i \in [0,1]$ be each feature's persistence. The unlabeled-image loss is

$$ \mathcal{L}_{\text{dec}}(q) = \sum_i \min(p_i,\, 1 - p_i), $$

which is zero only when every candidate grain is either sharply walled off ($p_i \approx 1$) or not a separate grain at all ($p_i \approx 0$). Its gradients act only on the pixels that create or destroy each feature. Those pixels are the saddle points where a faint boundary is weakest, so the loss concentrates on the low-contrast gaps where cross-alloy transfer fails.

The claim we will test is specific. On a held-out alloy, fine-tuning with $\mathcal{L}_{\text{dec}}$ on unlabeled target images should reduce grain-count and grain-size error more than pixel-level entropy minimization, pseudo-label self-training, or morphological gap closing. It should also reduce boundary overestimation.

Research Program

The first component is measurement. Every metallographic segmentation paper in our file either trains and tests within one alloy family or pools alloys. Microstructure Instance Segmentation from Aluminum Alloy Metallographic Image Using Different Loss Functions benchmarks five mask losses on a single 5-series aluminum dataset. An Improved U-Net Image Segmentation Method and Its Application for Metallic Grain Size Statistics trains a Focal-plus-Dice U-Net on SGMD, pooling six alloys: nickel-base alloy, low-carbon steel, austenitic steel, pure iron, yellow brass and ferrite steel. Both papers motivate the gap. Neither says what happens when the test alloy was never seen.

We will re-split SGMD into six leave-one-alloy-out folds. Each fold trains on five alloys, treats the held-out alloy's training-split images as unlabeled, and evaluates on its test images. The gap between pooled and held-out performance is the first quantified image-space measure of material specificity. SGMD has 60 images, roughly ten per alloy, so every held-out result will be reported per image with bootstrap intervals and several random seeds. We will not report single averages.

The second component is the adaptation method. The source model is the Focal-plus-Dice U-Net from the SGMD paper, which reproduces the strongest existing recipe. Adaptation runs a few hundred steps on target images with $\mathcal{L}_{\text{dec}}$. The supervised source loss stays on as an anchor so that the network cannot satisfy decisiveness trivially by predicting "no boundaries anywhere". We will also test whether the loss helps when added during source training, since sharper enclosure might generalize by itself. Persistence is computed with CubicalRipser on downsampled tiles, following the cardiac paper's accelerated pipeline.

The third component is a boundary-thickness analysis. Microstructural segmentation using a union of attention guided U-Net models with different color transformed images reports that its models overestimate boundary thickness on MetalDAM because boundary pixels are scarce. A decisiveness loss should sharpen the saddle regions where regions merge. We will measure predicted boundary width against ground-truth width before and after adaptation, to test whether thickening falls as a side effect.

The fourth component is a negative control. MetalDAM's classes are matrix, martensite/austenite, precipitates, austenite and defects. They form blobs inside a matrix, not a space-filling cellular network, so the closed-cell premise does not apply there. If $\mathcal{L}_{\text{dec}}$ helps on MetalDAM as much as on SGMD, the gain comes from generic sharpening and not from the topological prior. We will read it that way.

Baselines

The naive reference point is the source-only U-Net applied zero-shot to the held-out alloy with no adaptation. Every method is judged by how much of the gap between this model and a pooled model it closes. As an upper reference, we train a model with target labels included; on pooled SGMD this recipe reports MIoU 0.752, accuracy 0.97, precision 0.98 and F1 0.96 in An Improved U-Net Image Segmentation Method and Its Application for Metallic Grain Size Statistics. We found no reported result on Lacuna for leave-one-alloy-out evaluation on SGMD or any other metallographic dataset, so the held-out source-only numbers will be established here.

The strongest existing supervised competitor is the same improved U-Net with Focal-plus-Dice loss, DropBlock and its preprocessing. We reproduce it exactly, since it is the only published model trained across all six SGMD alloys. As a second architecture baseline we add a reverse-attention decoder of the kind in Parallel Res2Net-based Network with ReverseAttention for Polyp Segmentation. That decoder erases confident interiors so later layers concentrate on the boundary perimeter, and it reports precision of 81.14% to 88.94% on polyp benchmarks. Including it asks whether boundary-focused architectures from medical imaging close the material gap without any adaptation. On MetalDAM, the reference number is the attention-guided dilated U-Net ensemble at mIoU 0.677 from Microstructural segmentation using a union of attention guided U-Net models with different color transformed images.

The unsupervised adaptation baselines are pixel entropy minimization, confidence-thresholded pseudo-label self-training, and morphological post-processing. The post-processing applies skeletonization, bridges dangling endpoints within a distance threshold, and removes cells below a minimum area. It is the classical way to force closed cells.

Fairness is handled as follows. All adaptation methods start from the same source checkpoint and see the same unlabeled target images. They get the same number of adaptation steps and a matched hyperparameter search of twenty configurations each. Hyperparameters are chosen on a source-alloy validation fold, never on target labels. Post-processing thresholds get the same search on the same fold.

The ablation that isolates the key ingredient replaces $\mathcal{L}_{\text{dec}}$ with a pixel-wise analogue, $\sum_x \min(q_x, 1-q_x)$. This term pushes each pixel, rather than each topological feature, toward a decisive value, and it keeps everything else identical. A second ablation substitutes a fixed-count Betti loss whose target is the source-domain mean grain count. Its purpose is to show directly that count priors break under material shift.

Beating the baselines means lower held-out grain-count error and lower ASTM grain-size-number error than all three unsupervised baselines and the pixel-wise ablation, with bootstrap intervals that exclude zero on at least four of six folds. Boundary F1 at a two-pixel tolerance must not fall.

Why not just…?

Why not just label a few images of the new alloy and fine-tune? Few-shot fine-tuning is the honest industrial answer, and it may beat our method. We therefore include one-shot and three-shot supervised fine-tuning as reference points and report how many labeled images $\mathcal{L}_{\text{dec}}$ is worth. If one labeled image matches it, the method's value is limited to settings where no expert annotation is available. It could still complement few-shot labels, and we test the combination.

Why not just close gaps with morphology after prediction? This is the most serious threat, because endpoint bridging directly enforces closed cells. An Improved U-Net Image Segmentation Method and Its Application for Metallic Grain Size Statistics found that classical watershed and morphological pipelines over-segment and break edges on poorly etched images when used as the primary segmenter. That finding does not settle whether they work as a cleanup step on top of a network. Our expectation is that post-processing can join nearby endpoints but cannot recover a boundary the network barely registered, and cannot distinguish a real faint boundary from a scratch. The loss changes the features themselves during adaptation. The head-to-head grain-count comparison settles the question. If post-processing matches us, we will report that the gain comes from output topology alone, and the adaptation claim fails.

Why not just minimize prediction entropy or self-train on pseudo-labels? Both are standard label-free adaptation methods and both sharpen predictions. Neither distinguishes a thin gap that merges two grains from harmless uncertainty inside a grain. One mis-set pixel at a saddle point changes the grain count, while hundreds of uncertain interior pixels change nothing. The pixel-wise decisiveness ablation is built to measure exactly this difference.

Why not just normalize color or ensemble color spaces? The HSV/YUV ensemble reaches 0.677 mIoU on MetalDAM but trains three networks. Its authors still report boundary overestimation, and color transforms depend on etchant chemistry, which is what changes between alloys. We include per-image color normalization with the source-only model as an additional baseline. It is cheap to run, so we run it rather than argue it away.

Decisive Checks

The proposal succeeds if three results hold. First, leave-one-alloy-out evaluation must reveal a substantial held-out drop in grain-count accuracy relative to pooled training; this is the material-specificity measurement, and it is useful whether or not the method works. Second, $\mathcal{L}_{\text{dec}}$ must beat the pixel-wise ablation and the morphological post-processing baseline on grain-count and ASTM grain-size error across most held-out alloys. Third, the gain must shrink substantially on the MetalDAM negative control, where the closed-cell premise is false. We will report Betti error, grain-count error, ASTM grain-size-number error, tolerance-based boundary F1 and predicted boundary width. We will not headline pixel accuracy, which Microstructure Instance Segmentation from Aluminum Alloy Metallographic Image Using Different Loss Functions shows is inflated by the dominant background. If the first result holds but the second fails, the contribution narrows to a benchmark and a negative result about topological adaptation, and we will say so.