Measuring Boundary Blur in Millimetres to Set Segmentation's Spatial Scales

Segmentation networks are full of hidden length constants. Among them are the radius used to carve a thin "boundary band" around a coarse mask, the kernel size of the refinement convolution, and the distance at which a boundary loss starts penalizing errors. All of them are written in pixels. When the same tissue is imaged by a scanner with a different pixel size, or when a blurry polyp edge sits next to a sharp one, those constants stop meaning what their designers intended. The band is either too thin to contain the fuzzy transition or so wide that it swallows a small lesion. We propose replacing all of these constants with one quantity that can be measured from the image itself: the local edge blur scale, the physical width in millimetres over which intensity ramps from inside to outside, estimated with classical scale selection. That measured width, divided by the pixel spacing, sets the band radius, the dilation of the local refinement operator, and the tolerance of the boundary loss, pixel by pixel.

In two sentences for a colleague: low-contrast boundaries are not thin lines but transition zones with a measurable physical width, and that width is what every boundary operator's spatial scale should be tied to. If we measure it in millimetres and convert to pixels only at the last step, the same trained model should hold up across resolutions and across edges of very different sharpness, with no per-dataset retuning of band widths or loss thresholds.

Core Claim

The claim is that there are two separate sources of scale mismatch, and prior work fixes at most one. The first is grid mismatch: a fixed pixel footprint covers different physical areas at different resolutions. Resampling everything to a canonical spacing fixes this, and so does rewriting kernels in physical units. The second is ambiguity mismatch: within one image at one resolution, the transition zone of a flat polyp blending into mucosa can be several times wider than that of a pedunculated polyp with a crisp rim. Resampling does nothing for this second problem. We predict that a single edge-blur measurement, expressed in millimetres, corrects both at once. The prediction is testable: the gain should grow with both resolution shift and within-dataset variance of edge blur, and it should vanish on sharp-edged, fixed-resolution data.

The estimator is standard. For each pixel $x$ near a coarse boundary we compute the scale

$$\sigma(x) = s \cdot \arg\max_{t} \; t \,\lVert \nabla (G_t * I)(x) \rVert ,$$

where $I$ is the image, $G_t$ is a Gaussian of width $t$ pixels, $s$ is the pixel spacing in mm, and the factor $t$ normalizes gradient magnitude so the maximum lands at the edge's intrinsic blur. For an ideal blurred step edge, this scale-normalized response peaks near the blur width, which is why the estimate is intrinsic rather than tuned. The operator scale in pixels is then $r(x) = \kappa\,\sigma(x)/s$. The only free parameter is $\kappa$, which is dimensionless and shared across datasets.

How It Relates to Prior Work

The motivating evidence comes from papers that ran into this problem and named it. Polyper splits a coarse prediction into interior and "potential boundary" regions with fixed-radius erosion and dilation, then cross-attends from interior to boundary features. Its authors list fixed boundary widths as a limitation and call for adaptive ones. We keep Polyper's interior-to-boundary structure and replace its radius with $r(x)$. Boundary Loss for Remote Sensing Imagery Semantic Segmentation builds a differentiable boundary F1 surrogate with a pixel buffer zone and reports that the buffer width had to be retuned by hand between 10 m satellite and 30 cm aerial pixels. Training Deep Networks to be Spatially Sensitive approximates a weighted F-measure with fixed Gaussian kernels and flags the resulting resolution sensitivity as open. Both papers expose the grid problem. Neither addresses per-edge variation in blur.

The method comes from two sources. Boundary loss for highly unbalanced segmentation weights predicted probabilities by a precomputed ground-truth distance map. We compute that map in millimetres and divide it by the ground-truth-side blur scale $\sigma_G$, giving the loss

$$\mathcal{L}_{B} = \sum_x p_\theta(x)\,\frac{\phi_G^{\text{mm}}(x)}{\sigma_G(x)} .$$

Here $p_\theta$ is the predicted foreground probability, $\phi_G^{\text{mm}}$ is the signed distance to the ground-truth contour in mm, and $\sigma_G$ is the blur scale measured along that contour. The effect is that errors inside a genuinely ambiguous zone cost less than equal-sized errors at a crisp edge. That is both resolution-invariant and consistent with where annotators themselves disagree.

PARF-Net supplies the local-global routing idea: pixel-wise attention picks among fixed 3×3, 7×7 and 11×11 kernels, favoring small kernels at boundaries and large ones in interiors. We read its success as indirect evidence that the right receptive field is location-dependent. But its choices are learned from a fixed pixel bank, so a resolution shift moves every option at once.

Other hybrid designs fix their local and global scales in pixels. Dual-Kernel Adapter pairs 51×51 and 5×5 depthwise branches. Salient Object Detection in Low Contrast Images via Global Convolution and Boundary Refinement uses 7×1 and 1×7 global convolutions. CKD-TransBTS sidesteps the issue by evaluating only on 1 mm isotropic BraTS.

The closest cross-direction work is HRDA. It learns a per-pixel scale attention between a low-resolution context crop and a high-resolution detail crop. That is a learned local-global trade-off, but it was built on sharp driving scenes with crop scales tuned to 2048×1024. Our proposal differs because the local-global split is dictated by a measured physical quantity rather than learned without a reference, and it is aimed at boundaries whose ambiguity is the defining property.

Research Program

We build one refinement head that can be attached to an existing encoder-decoder, using a PVTv2 or Res2Net backbone as in the polyp literature. A coarse decoder produces $p_0$. The blur scale $\sigma(x)$ is computed on the input image along the 0.5 iso-contour of $p_0$ and diffused into a smooth field, using the pixel spacing $s$ from the image header or the dataset's stated ground sampling distance. This field then sets three things. It sets the per-pixel erosion and dilation radius $r(x)$ that defines Polyper-style interior and boundary regions, implemented as a soft band $\exp(-d(x)^2 / r(x)^2)$ so the band stays differentiable. It sets the dilation rate of the depthwise local-mixing convolution inside the band, rounded to the nearest integer or realized by bilinear sampling of a deformable offset grid. It also controls the extent of the global branch: outside the band, and where $r$ is large, features are drawn from a low-resolution context pathway, which replaces HRDA's learned scale attention with a σ-conditioned gate. The loss is area Dice plus $\mathcal{L}_B$.

The analytic part asks whether $\sigma$ is a meaningful quantity at all. On each dataset we measure the correlation between $\sigma$ at ground-truth contours and inter-annotator or inter-model disagreement width where multiple labels exist. We also measure how much $\sigma$ in mm drifts under controlled resampling. It should be nearly constant once the resampling scale is finer than the blur, and it should rise once downsampling itself becomes the dominant blur.

Baselines

The naive reference is the "just resample" pipeline: every image is resampled to one canonical spacing or matrix, then a Polyper-style model is trained with its default fixed pixel band and Kervadec's pixel-unit boundary loss. It gets the same backbone, the same epochs, and the same hyperparameter search budget, with the band radius tuned on validation at the canonical resolution. This is the baseline most likely to embarrass the proposal, because it removes grid mismatch for free.

The strongest boundary-refinement competitor is Polyper, which reports ETIS mDice of 86.51%. We rerun it with our backbone and tuning budget and also cite its published number. Beating it means exceeding that ETIS figure under the published protocol, and, more importantly, losing less Dice than Polyper when the test resolution is halved or doubled.

The strongest adaptive-receptive-field competitor is PARF-Net, which reports Synapse mean Dice of 84.27% and pancreas Dice of 72.86%. We run it with scale augmentation added so that it gets every chance to learn resolution robustness by itself. For the loss alone, the references are Boundary loss for highly unbalanced segmentation, which reports ISLES Dice rising from 0.575 with GDL to 0.656 with boundary loss, and the remote-sensing hybrid boundary loss, which reports 93.85% IoU on ISPRS Potsdam. We compare against both with their buffer and distance settings tuned at the training resolution and then frozen.

Three ablations isolate the key ingredient. In the first, $\sigma(x)$ is replaced by a single constant in mm, tuned once. This converts to physical units without local measurement, and it tells us whether local blur matters or physical units alone suffice. In the second, $\sigma$ is estimated from the gradient of $p_0$ rather than from the image. In the third, a learned width head predicts $r(x)$ with no σ supervision. If the constant-mm variant matches the full model, the per-edge measurement is not earning its place and the contribution collapses to unit bookkeeping.

Why not just…?

Why not just resample everything to one spacing? This removes grid mismatch, and at matched resolution it may well match our method. What it cannot do is widen the band at a flat, diffuse polyp edge while narrowing it at a crisp one within the same image. It also blurs fuzzy transitions further through interpolation, and HRDA found that downsampling to fit memory destroyed fine structures. We treat this as a real threat. The within-resolution blur-stratified analysis below is designed to settle it. If our gains appear only under resolution shift and not across blur strata, resampling plus the constant-mm ablation is the honest recommendation.

Why not just train with heavy scale augmentation and let the network learn robustness? Augmentation teaches invariance to the shifts it samples, but pixel-unit band radii and loss buffers stay fixed in pixels, so the label-side geometry remains mismatched. We test this directly by giving PARF-Net and Polyper the same augmentation and evaluating at scales outside the augmentation range. There, extrapolation, not interpolation, is what separates the approaches.

Why not make the band width a learnable parameter, or let a PARF-style router choose it? A learned per-pixel width can in principle discover blur. Nothing anchors it to physical units, though, so it inherits the training resolution. Dual-Kernel Adapter reports that its dynamic branch weighting remained preliminary. The unsupervised learned-width ablation measures this directly. If it matches the σ-driven model under cross-resolution testing, we would reframe σ as a supervisory target for that head rather than a fixed rule.

Why not fix boundaries with CRF post-processing? A CRF's pairwise kernels are also pixel-scaled, so they carry the same problem. Training Deep Networks to be Spatially Sensitive reports that moving boundary sensitivity into the loss removed CRFs at roughly 0.094 s versus about 1 s per image.

Proposed Experiments

We run three regimes. Polyp segmentation uses Kvasir-SEG and CVC-ClinicDB for training, with CVC-ColonDB, CVC-300 and ETIS as unseen sets. These sets come from different endoscope setups, giving a native resolution and blur shift, and we add synthetic test-time rescaling at 0.5×, 0.75×, 1.5× and 2×. Synapse multi-organ CT and ACDC cardiac MRI test anisotropic and variable voxel spacing: we train at one in-plane spacing and test at resampled spacings, with pancreas and thin myocardium as the low-contrast cases. ISPRS Potsdam, trained at native ground sampling distance and tested on progressively downsampled tiles, reproduces the satellite-versus-aerial retuning problem that the remote-sensing boundary loss paper described.

Metrics are Dice and mIoU; 95th-percentile Hausdorff distance in mm, never pixels; boundary F1 at fixed millimetre tolerances; and a resolution-sensitivity score, the drop in Dice from native to each rescaled test.

Three checks decide the question. First, the resolution-sensitivity curve of our model should be flatter than that of both resample-plus-Polyper and augmented PARF-Net, with the gap widening at scales outside training. Second, test boundaries are stratified by measured $\sigma$ in mm at a single fixed resolution. Our advantage over the constant-mm ablation should be concentrated in the widest-blur stratum and near zero in the sharpest. That gradient is the signature of the claim, and its absence would falsify it. Third, on Potsdam the band and loss hyperparameters tuned once must transfer across ground sampling distances with no retuning, while the pixel-buffer baseline is shown to need retuning. The remote-sensing paper reported that retuning need but did not quantify it.