Papers
Topics
Authors
Recent
Search
2000 character limit reached

Pixel-wise Modulated Dice Loss

Updated 28 February 2026
  • Pixel-wise Modulated Dice (PM Dice) is a loss function that augments traditional Dice loss by incorporating pixel-level modulation to tackle both class and difficulty imbalances in segmentation tasks.
  • The method introduces a per-pixel modulating factor computed from the absolute difference between ground truth and predictions, with a class-specific exponent to emphasize challenging regions while preserving Dice geometry.
  • Empirical results on benchmarks like Kvasir-SEG, ACDC, and MSSEG-2 demonstrate improved segmentation accuracy, boundary adherence, and better detection of small or low-contrast lesions.

Pixel-wise Modulated Dice (PM Dice) is a loss function developed for medical image segmentation tasks, designed to explicitly address both class imbalance and 1^ by introducing pixel-level modulation into the classical Dice loss. The approach builds upon the geometric properties of Dice-based overlap measures while selectively focusing training emphasis on harder-to-classify regions, yielding improved segmentation outcomes in diverse medical imaging benchmarks (Hosseini, 17 Jun 2025).

1. Mathematical Definition and Formulation

Let yi,c{0,1}y_{i,c} \in \{0,1\} denote one-hot ground-truth labels and pi,c[0,1]p_{i,c} \in [0,1] denote model-predicted probabilities for pixel ii and class cc in an image segmentation problem with CC classes. The PM Dice loss introduces a per-pixel, per-class modulating factor mi,cm_{i,c} defined as

mi,c=yi,cp~i,cγcm_{i,c} = |y_{i,c} - \tilde{p}_{i,c}|^{\gamma_c}

where p~i,c\tilde{p}_{i,c} is the predicted probability for pixel ii and class cc, detached from the computation graph (i.e., "stop-gradient"), and γc0\gamma_c \geq 0 is a class-specific focusing parameter.

The PM Dice loss is then given by

LPM Dice=11Cc=1C2imi,cyi,cpi,c+ϵimi,c(yi,c2+pi,c2)+ϵL_{\text{PM Dice}} = 1 - \frac{1}{C} \sum_{c=1}^C \frac{2 \sum_i m_{i,c} y_{i,c} p_{i,c} + \epsilon}{\sum_i m_{i,c}(y_{i,c}^2 + p_{i,c}^2) + \epsilon}

where ϵ\epsilon is a smoothing constant (typically 1×1061\times 10^{-6}).

With γc=0\gamma_c=0, mi,c1m_{i,c} \equiv 1 and LPM DiceL_{\text{PM Dice}} reduces to the conventional Dice loss (Hosseini, 17 Jun 2025).

2. Rationale: Addressing Imbalance in Segmentation

Medical image segmentation presents substantial class imbalance, e.g., sparse target structures within large backgrounds. Conventional Dice loss, based on set overlap, handles class imbalance more robustly than cross-entropy by directly maximizing proportionate intersection.

However, a secondary, less-addressed "difficulty imbalance" arises: within any class, easy pixels (predictable or interior regions) outnumber hard pixels (ambiguities near boundaries or in small lesions). Standard training drives down error where it is already low, leaving the most challenging pixels insufficiently weighted (Hosseini, 17 Jun 2025).

The pixel-wise modulating term mi,cm_{i,c} counteracts this by upweighting hard-to-predict (large yi,cpi,c|y_{i,c} - p_{i,c}|) pixels and downweighting easy ones, redistributing optimization effort toward ambiguous or error-prone regions. Fixing p~i,c\tilde{p}_{i,c} (no gradient) preserves the Dice loss's geometric interpretation as a set-similarity metric.

3. Implementation Characteristics and Hyperparameters

The PM Dice loss requires minimal departure from standard Dice implementations. The essential modifications include a per-pixel absolute value, exponentiation, and multiplication—incurring less than 5% computational overhead in practice. The computation for each batch proceeds as follows:

  1. p~\tilde{p} \leftarrow stop_gradient(pp)
  2. For each pixel ii and class cc, compute mi,cyi,cp~i,cγcm_{i,c} \leftarrow |y_{i,c} - \tilde{p}_{i,c}|^{\gamma_c}
  3. Numerators: Nc2imi,cyi,cpi,c+ϵN_c \leftarrow 2 \cdot \sum_i m_{i,c} y_{i,c} p_{i,c} + \epsilon
  4. Denominators: Dcimi,c(yi,c2+pi,c2)+ϵD_c \leftarrow \sum_i m_{i,c}(y_{i,c}^2 + p_{i,c}^2) + \epsilon
  5. Aggregate: LPM Dice11Cc=1C(Nc/Dc)L_{\text{PM Dice}} \leftarrow 1 - \frac{1}{C} \sum_{c=1}^C (N_c / D_c)

The primary hyperparameter is γc\gamma_c, controllable per class. In balanced or mildly imbalanced settings, γc=1\gamma_c=1 for all classes is standard. In severe imbalance, a higher γ\gamma can be set for foreground compared to background (e.g., γfg=2\gamma_{\text{fg}}=2, γbg=1\gamma_{\text{bg}}=1) to prevent the majority class from dominating (Hosseini, 17 Jun 2025).

Parameter Symbol Default / Example Value
Smoothing constant ϵ\epsilon 1×1061\times10^{-6}
Focusing param γc\gamma_c $1$ (foreground: $2$)
Stop-gradient p~\tilde{p} Copy of pp (no grad)
Batch structure Mini-batch, vectorized

4. Empirical Benchmarks and Performance

Evaluation of PM Dice on three standard medical segmentation benchmarks demonstrates consistent improvements over both standard Dice and prior difficulty-aware variants:

  • Kvasir-SEG (polyp, binary):
    • Standard Dice: mDice 88.76%
    • PM Dice: mDice 90.61%, mIoU 85.37%, highest NSD (54.9%), precision 92.61%, recall 91.57%
  • ACDC (cardiac MRI, 3-class):
    • Standard Dice: mDice 90.02%
    • PM Dice: mDice 91.88%, mIoU 85.35%, mNSD 87.92%
  • MSSEG-2 (MS lesions, binary):
    • Standard Dice: mDice 66.41%
    • PM Dice: mDice 69.07%, mIoU 53.12%, mNSD 66.93%

PM Dice also demonstrates superior qualitative performance, with improved adherence to object boundaries and ability to segment small, low-contrast lesions that are frequently missed by previous methods (Hosseini, 17 Jun 2025).

PM Dice extends prior strategies by directly incorporating pixel-level classification difficulty into the loss function through explicit modulation. Prior work on dual-sampling modulated Dice loss (DSM Dice) (Liu et al., 2020) also addresses imbalance, but via two branches with sampler-driven cost bias (uniform for large structures, re-balanced for small) and an epoch-dependent convex combination. In contrast, PM Dice provides a unified, single-branch, per-pixel continuous weighting, requiring no explicit sampler design or multi-branch architecture. PM Dice's stop-gradient design maintains the loss's geometric Dice interpretation throughout optimization (Hosseini, 17 Jun 2025, Liu et al., 2020).

6. Guidelines for Practical Use

PM Dice is amenable to U-Net and encoder–decoder architectures as a drop-in replacement for standard Dice loss. Recommended default settings include γc=1\gamma_c=1 for all classes, with increased γfg\gamma_{\text{fg}} when foreground structures are significantly under-represented. Compound loss formulations (PM Dice plus cross-entropy or focal cross-entropy) yield modest additional improvements, but are optional given PM Dice’s intrinsic handling of both class and difficulty imbalance. It is essential that the predicted logits used for modulation are detached to preserve proper optimization geometry (Hosseini, 17 Jun 2025).

7. Significance, Limitations, and Outlook

PM Dice demonstrates that a computationally lightweight, pixel-level weighting scheme can robustly address both major sources of error in medical segmentation—class and difficulty imbalance—while preserving Dice loss's desirable geometric properties. Major advantages include negligible computational burden, minimal parameter tuning, and broad empirical gains (improvements of 1–3 percentage points, especially in boundary adherence and minority-structure recall). A plausible implication is that continued refinement or integration of pixel-wise modulation strategies with geometric losses could yield further segmentation improvements in challenging class-imbalanced domains (Hosseini, 17 Jun 2025).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Pixel-wise Modulated Dice (PM Dice).