Neighbor-Aware Calibration of Segmentation Networks with Penalty-Based Constraints

Balamurali Murugesan, Sukesh Adiga Vasudeva, Bingyuan Liu, Hervé Lombaert, Ismail Ben Ayed, Jose Dolz

TL;DR

Deep segmentation networks are notoriously overconfident, largely because existing calibration methods treat pixels as isolated entities and ignore spatial context. This paper introduces NACL (Neighbor Aware CaLibration), a simple yet principled approach that enforces penalty-based equality constraints on network logits using surrounding pixel class proportions. NACL consistently mitigates overconfidence while simultaneously boosting segmentation accuracy across diverse medical imaging benchmarks.

What Problem Does This Paper Address?

When deep neural networks are deployed in safety-critical domains like medical image computing, knowing how confident a model is matters just as much as its raw accuracy. Unfortunately, modern deep networks suffer from severe miscalibration—they tend to make highly overconfident, incorrect predictions.

While many calibration techniques exist (e.g., focal loss, temperature scaling, label smoothing), they were originally designed for image classification. When applied to dense prediction tasks like semantic segmentation, these methods treat each pixel independently. They fail to account for spatial dependencies and local structures, such as the ambiguous boundaries between neighboring organs.

A recent method called Spatially Varying Label Smoothing (SVLS) attempted to fix this by applying a spatial Gaussian kernel to soften ground-truth labels. However, the authors of this paper reveal that SVLS lacks a mechanism to balance its spatial constraint with the primary segmentation objective, which can hinder optimization.

Methods

The authors first re-frame SVLS through the lens of constrained optimization, proving that it implicitly minimizes standard cross-entropy while forcing softmax predictions to match the soft class proportions of neighboring pixels.

To overcome the limitations of SVLS, they propose NACL (Neighbor Aware CaLibration). NACL introduces two key innovations:

  1. Logit-Space Constraints: Instead of applying constraints to the bounded softmax probabilities, NACL applies equality constraints directly to the unconstrained logit space ($l$). This restricts the absolute magnitude of the logits, naturally curbing overconfident predictions.
  2. Explicit Penalty Control: NACL formulates calibration as an unconstrained optimization problem using a soft linear ($L_1$) penalty controlled by a hyperparameter $\lambda$: $$\min_\theta \mathcal{L}_{CE} + \lambda \sum_k |\tau_k - l_k|$$ where $\tau_k$ represents the target neighborhood class proportion prior, and $l_k$ is the predicted logit for class $k$. This gives explicit control over how strongly the spatial calibration constraint is enforced relative to the cross-entropy segmentation loss ($\mathcal{L}_{CE}$).

Datasets

The approach was comprehensively validated on six public multi-class medical image segmentation benchmarks covering different modalities (MRI and CT) and target organs:

  • ACDC: Cardiac cine-MRI (3 structures)
  • BraTS 2019: Brain tumor multi-channel MRI (3 regions)
  • FLARE: Abdominal CT scans (4 organs)
  • PROSTATE: Prostate MRI (2 zones)
  • KiTS: Kidney tumor CT scans (2 classes)
  • MRBrainS18: Brain tissue MRI (3 classes)

Key Insights and Ideas

  • Logits over Softmax: Imposing constraints on the logit space yields significantly better calibration and segmentation performance than working in the softmax space. Because the logit range is much larger, it allows for finer optimization control.
Impact of applying the penalty over softmax vs logit predictions. Enforcing constraints on the logit space (circles) consistently yields lower ECE and higher DSC.
  • The "Best of Both Worlds" Logit Distribution: Standard label smoothing squashes the distance between the winning logit and other classes too aggressively, which can destroy semantic information needed for accurate segmentation. NACL keeps the magnitude of the winning logit low (preventing overconfidence) while pushing competing logits a safe distance away, preserving discriminative power.
  • Model Agnostic: NACL acts as a drop-in loss function regularizer. The authors demonstrated its robustness by plugging it into five distinct architectures, including CNNs (UNet, AttUNet, UNet++, nnUNet) and Vision Transformers (TransUNet).

Key Results

NACL achieves a rare "win-win" in machine learning: it dramatically improves calibration error without sacrificing segmentation accuracy.

Radar plots showing the trade-off between calibration (ECE, brown) and discriminative performance (DSC, blue). An ideal model maximizes the blue area and minimizes the brown area; NACL consistently achieves the best balance.
  • Segmentation Performance: As detailed in the paper's comprehensive evaluations, NACL achieved the highest mean Dice Similarity Coefficient (DSC) in 10 out of 12 evaluated settings, outperforming state-of-the-art losses like Focal Loss and Margin-based Label Smoothing (MbLS).
  • Calibration Reliability: NACL consistently yielded the lowest Expected Calibration Error (ECE). For example, on the ACDC dataset, NACL cut the ECE down to 0.048, compared to 0.137 for standard Cross-Entropy+Dice loss and 0.091 for SVLS.
  • Data Scarcity Robustness: When training data was restricted to just 25% or 50% of the datasets, NACL maintained stable calibration performance, effectively managing epistemic (knowledge-based) uncertainty.

Limitations and Future Work

The authors note two primary limitations of the current NACL framework:

  1. Intensity Blindness: The neighborhood prior ($\tau$) is computed solely from the spatial distribution of the ground-truth labels. It completely disregards underlying image intensity variations, which often correlate with annotation uncertainty.
  2. Simple Penalty Functions: The study only explored linear ($L_1$) and quadratic ($L_2$) penalties.

Future work will focus on incorporating image intensity information into the spatial constraint and exploring more sophisticated optimization strategies, such as log-barrier methods, to enforce the constraints more effectively.

Summary updated

BibTeX
@article{murugesan2025neighbor,
  author = {Balamurali Murugesan and Sukesh Adiga Vasudeva and Bingyuan Liu and Hervé Lombaert and Ismail Ben Ayed and Jose Dolz},
  title = {{Neighbor-Aware Calibration of Segmentation Networks with Penalty-Based Constraints}},
  journal = {Medical Image Analysis},
  year = {2025},
  doi = {10.1016/j.media.2025.103501},
}
Figure