Manuscript Offprint
arXiv:2611.09120Finite-sample Calibration Guarantees for Binary Segmentation
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Machine learning-based segmentation models are frequently miscalibrated, producing for each pixel a label prediction whose associated confidence does not accurately reflect the true underlying probability. This limitation is particularly critical in high-stakes applications such as medical image segmentation. Although several calibration methods have been proposed, only a small subset of them provides theoretical guarantees on the calibration error, i.e., they do not typically ensure that, with high probability, the model exhibits a low calibration error. In this work, we develop a post-hoc calibration method for which formal calibration guarantees can be established. To achieve this, we derive from standard concentration inequalities an improved theoretical bound that explicitly accounts for the spatial dependence inherent in binary segmentation outputs. We empirically demonstrate that the proposed calibrator satisfies the derived guarantee and outperforms existing post-hoc calibration approaches.
1 Introduction
The calibration of a segmentation model is a fundamental task in machine learning that needs to be addressed in order to align the predicted confidence of a model with the true reliability of its prediction. It is essential to obtain reliable models for real-world applications. In the context of deep learning, the confidence of a model refers to the probability it assigns to its predicted output. Ideally, this confidence should faithfully reflect the true likelihood of correctness. However, modern neural networks tend to be overconfident, which means that their predicted confidence scores are poorly aligned with the actual accuracy (Guo et al., 2017; Ovadia et al., 2019). This misalignment becomes particularly crucial in critical-domain applications such as medical image segmentation, where erroneous predictions can have severe consequences. In such settings, a miscalibrated model may assign high confidence to incorrect segmentations, leading practitioners to place unwarranted trust in flawed outputs. In contrast, a well-calibrated model ensures that a predicted confidence of, say, 90% corresponds in the long run to a true correctness rate of approximately 90% (Dawid, 1982).
The calibration problem has been extensively studied, and existing approaches can broadly be categorized into three groups (Wang et al., 2023). Post-hoc calibration methods operate after training, adjusting the model's output probabilities without modifying its parameters. Classical techniques include Platt scaling (Platt et al., 1999), Temperature Scaling (Guo et al., 2017), Dirichlet calibration (Kull et al., 2019), Histogram Binning (Zadrozny & Elkan, 2001), Meta-cal (Ma & Blaschko, 2021), and Isotonic Regression (Zadrozny & Elkan, 2002). Although originally introduced for classification, these methods can be applied to segmentation by treating each pixel independently. Moreover, there are also spatially aware extensions, such as (Ding et al., 2021; Rousseau et al., 2025; Küppers et al., 2022). The second group, Train-time calibration, has also been widely explored. Mixup (Zhang et al., 2018), CutMix (Yun et al., 2019), and label smoothing (Szegedy et al., 2016; Müller et al., 2019) regularize confidence by exposing the model to soft
*MH is also a member of NAWI Graz www.navigraz.at and BioTechMed Graz https://biotechmedgraz.at/de/ or interpolated targets. This group also includes methods that modify the training loss to penalize miscalibration: representative examples in the classification setting include Focal Loss (Lin et al., 2017), FLSD (Mukhoti et al., 2020), MMCE (Kumar et al., 2018), and DECE (Bohdal et al., 2023), all of which encourage the model to reduce overconfidence while preserving discriminative performance. Several approaches have also been developed specifically for segmentation tasks, such as MDCA (Hebbalaguppe et al., 2022), as well as methods tailored to the medical imaging domain (Barfoot et al., 2024; 2026; Murugesan et al., 2025; 2023). The third group of calibration approaches are uncertainty estimation methods, which includes Monte Carlo dropout techniques (Gal & Ghahramani, 2016; Kendall & Gal, 2017) and Deep Ensemble Networks (Lakshminarayanan et al., 2017; Mehrtash et al., 2020). However, these methods, rather than recalibrating the model, primarily identify and highlight regions of high uncertainty.
In contrast to the works mentioned so far, which are purely empirical, methods that use calibration data to equip a pre-trained machine learning model with theoretical guarantees have seen a strong interest in the past years. Rooted in the work of Vovk et al. (2005), several works leverage statistical learning theory, and in particular conformal prediction, to provide coverage guarantees for segmentation models (Brunekreef et al., 2024; Mossina & Friedrich, 2025; Viti et al., 2026; Bereska et al., 2025; Teng et al., 2023; Liu et al., 2025). An interesting connection between conformal prediction and confidence calibration is developed by Xi et al. (2025). The authors first show that standard calibration approaches fail to improve conformal prediction, then propose a tailored calibration method designed to enhance prediction set efficiency. These works, however, focus primarily on constructing reliable prediction sets, rather than recalibrating pre-trained models with provable guarantees on the calibration error itself.
A notable exception is the work of Gupta et al. (2020); Gupta & Ramdas (2021), which endows histogram-binning calibration with finite-sample statistical guarantees for classification tasks. Following their notation, let the feature and label space be and . We have at our disposal a pre-trained predictor , where is the (uncalibrated) predicted probability that , and a calibration dataset . The pre-trained model belongs to the space of all measurable functions from . We would like to construct a calibrator , that recalibrates given the dataset . We denote the calibrated predictor as . A predictor is perfectly calibrated if , which, in the binary case, corresponds to . While the latter condition is impossible to guarantee in a finite-sample setting, we would like to have a guarantee on the calibration error using the following notions:
Definition 1.1. (Marginal calibration). Let and . A calibrator is said to be -marginally calibrated if for every predictor and distribution over
Definition 1.2. (Conditional calibration). Let and . A calibrator is said to be -conditionally calibrated if for every predictor and distribution over
The fundamental distinction between the two definitions is that in the marginal case the probability is taken over both and , meaning that the probability holds only on average over . Conditional calibration instead, which implies marginal, requires the bound to hold uniformly in .
The seminal work of Gupta et al. (2020); Gupta & Ramdas (2021) remains confined to the classification setting. Our contribution builds directly on this line of work and extends it beyond classification. To the best of our knowledge, no existing work provides marginal and conditional guarantees in the segmentation setting. One reason is that standard approaches require large amounts of independent and exchangeable calibration data — an assumption that breaks down in segmentation, where pixel-wise predictions within an image are spatially correlated. This paper fills this gap by leveraging concentration inequalities, specifically adapted to account for spatial pixel correlation in our setting, to derive calibration guarantees for segmentation models.
The main theoretical tool used in (Gupta et al., 2020; Gupta & Ramdas, 2021) to bound the calibration error is Hoeffding's inequality (Hoeffding, 1963), which provides concentration for sums of bounded i.i.d. random variables. In segmentation, however, the predictor outputs a probability for each pixel, and the spatial correlation between pixels violates the i.i.d. assumption, making such inequalities inapplicable. While extensions to the non-i.i.d. setting exist — including martingale-based results such as Azuma (1967) and Freedman (1975) inequalities, and concentration under -mixing conditions (Yu, 1994; Mohri & Rostamizadeh, 2010) — these do not capture the structured spatial dependencies inherent to segmentation outputs.
Image segmentation outputs can naturally be modeled as random fields: each pixel label depends not only on its own features but also on the label of its spatial neighbors, inducing dependencies across the output map that are well captured by random field models such as Markov Random Fields (Li, 2009; Zoltan & Josiane, 2012). Bounding the calibration error in this setting therefore requires concentration inequalities that explicitly account for such spatial dependencies. Early approaches to random fields relied on information-theoretic tools: Marton (1998; 2003) and Samson (2000) established concentration results for -mixing processes using transportation and Pinsker inequalities, albeit restricted to exponential bounds. A significant step forward was achieved by Chazottes et al. (2007), who proposed a coupling-based framework for random fields indexed by that yields concentration inequalities depending on the strength of spatial dependence. A parallel martingale-based approach was developed in (Kontorovich & Ramanan, 2008), yielding concentration bounds for Markov and hidden Markov chains in terms of mixing coefficients. More recently, Garnier & Langhendries (2022) established a Hoeffding-type inequality specifically for non-causal random fields. Finally, Chazottes et al. (2026) provides sharp Gaussian concentration criteria for Gibbs measures and Markov random fields on .
Our contribution In this work, we address the problem of calibration for binary segmentation models. We first derive an improved concentration inequality tailored to variables exhibiting the structured spatial dependence of binary segmentation outputs. Building upon the framework of (Chazottes et al., 2007), we model the spatial relationship between pixels and obtain a tighter theoretical bound. We then apply the bound to the calibration setting: we construct a calibrator following the idea of Gupta & Ramdas (2021), and establish that the calibrator satisfies the theoretical guarantees provided by our bound. This result formally justifies its application in the segmentation setting. A key insight is that treating each individual pixel prediction as a data point vastly increases the effective size of the calibration set. As a result, our method achieves tight statistical guarantees with a comparably small number of calibration images — even with only 50 images — making it practical for real-world applications where calibration data is scarce. Beyond providing theoretical guarantees, we also show that the calibrator even practically outperforms other post-hoc calibration approaches that do not come with such guarantees.
The outline of the paper is the following: In Section 2 we derive the improved theoretical bound and in Section 3 we show how the bound can be exploited to obtain statistical guarantees for calibration errors in the segmentation setting. Finally, in Section 4 we show how to estimate the bound and in Section 5 we empirically show the validity of our approach.
We are going to improve the bound through two assumptions that hold true in our setting, namely: is a Bernoulli alphabet and g is the average of Bernoulli variables.
2.1 Bernoulli alphabet
To establish the concentration inequality, we use a martingale argument which decomposes the quantity of interest as the sum of martingale differences McDiarmid et al. (1989). For let be the sigma-field generated by the random variables . Then, following Chazottes et al. (2007, Section 2.1), we write
Further, we write for the values at sites ordered before i, and define
For a Bernoulli alphabet , a computation using the law of total expectation (see A.1) yields:
To obtain the concentration inequality, we have to bound the moment generating function (MGF) of each variable . However, Chazottes et al. (2007, Lemma 1) uses only the range of , namely , to obtain such a bound. We, instead, make use of the fact that is a scaled centered Bernoulli with conditional variance , and exploit the terms to provide a tighter MGF bound than the range-only estimate. This choice does not come from a formal comparison between the Bennett and the range-only bounds, but is rather qualitative, driven by the intuition, later supported by the experiments, that the conditional variance is typically small and thus worth retaining in the bound. To do that, we apply Bennett's inequality (Boucheron et al., 2013, Theorem 2.9) and prove it in Appendix A.2:
Lemma 2.1 (Bennett bound). Let and , then :
2.2 The coupling matrix and the function g
Now that we have bounded the MGF of by , we need to bound the increment . To this aim, for a given configuration , we define the coupling matrix as
where denotes the maximal coupling (Lindvall, 2002) of the conditional distributions and . Intuitively, measures the influence of site on site : it is the probability that two coupled copies and of the process, agreeing on the past , but initialized with opposite values at site , still disagree at site . Notice that for we have and that, in case of independent random variables, the matrix would be the identity matrix. With in hand, we can now bound via the variation of . In our setting, is the empirical mean of Bernoulli variables, and its variation at site is
The last step is using Chazottes et al. (2007, Eq. 5) to bound the increment by . In our case, since for all , and defining to remove the dependence on , this simplifies to (see Appendix A.3):
where denotes the -th row sum of , i.e., the cumulative forward influence of element on all subsequent elements. A more detailed discussion and practical estimation of is provided in Section 4.
2.3 Main Theorem
We now state the concentration inequality and prove it in Appendix A.4.
Theorem 2.2 (Concentration for Bernoulli mean). Let . Define the coupling matrix as in Section 2.2, , and with . Set
Then for all :
Notice that the notation relies on having a natural total order. For variables indexed in , one fixes an arbitrary enumeration and writes . The full extension to is given in Appendix A.5 and involves mainly this notational variation.
3 Calibration Guarantees
We are interested in obtaining calibration error bounds in the segmentation setting where the i.i.d. assumption does not hold due to the spatial dependence between pixels. Let denote pixel positions. Let and be the feature and label spaces of images and their segmentation masks, respectively. Let be a pre-trained predictor, where predicts the probability of . We seek a calibrator inducing a calibrated predictor , which maps each pixel-wise confidence to a revised confidence score. We are going to use a binning approach, first introduced in (Zadrozny & Elkan, 2001) and more recently used in (Gupta et al., 2020; Gupta & Ramdas, 2021). Let be a dataset featuring images and binary segmentations. We partition the dataset into two subsets and , using the first one to compute the binning scheme and the latter to construct the calibrator .
3.1 Binning scheme
The first step is to create a binning scheme that provides a partition of the pixel positions. Following the definition of Gupta et al. (2020), a binning scheme is any partition of into non-overlapping intervals such that and for . Therefore, given and , the partition for a generic image is defined as
A naive way to construct the binning scheme is to choose fixed-width bins such that , and . This binning scheme requires no held-out data, but tends to produce highly imbalanced bins, since overconfident predictors typically assign extreme probabilities (close to 0 or 1) to most pixels. Therefore, we empirically find a uniform-mass binning scheme through quantiles (Gupta & Ramdas, 2021). The bins are defined as
where is the -th quantile, empirically estimated using the images in .
3.2 Calibrator
Now that we have a binning scheme , we partition the pixels of the images of using , and we define the calibrated predictor as:
As an example, suppose that on the calibration dataset bin has an average raw confidence (predicted by ) of 0.8, but only 70% of those predictions have ground-truth equal to 1. Then, for a new test point , the calibrator replaces the raw confidence with the empirical label frequency observed in bin on the calibration set, i.e., if . We note that is to be understood as conditioned on the binning scheme , so that is treated as a constant and the only source of randomness are the Bernoulli labels. The calibration procedure is summarized in Algorithm 1.
3.3 Calibration Guarantees Theorems
We now use the theory derived in Section 2 to bound the calibration error with the following theorems, which are all proved in Appendix A.6. Before stating the calibration theorems, observe that for a fixed bin , is the empirical mean of dependent Bernoulli variables. Thus, plays the role of , with being the labels of pixels falling in bin , i.e., .
Theorem 3.1 (Per-bin concentration). Let be a fixed binning scheme. Then, given a calibration set , let be the corresponding partitions and define the observed frequency in bin as in equation 8. Denote as a realization of the binning event that fixes the calibration labels in the corresponding bins, and fix a bin . Let be the coupling matrix (as defined in Section 2.2) of image conditioned on the binning event (i.e. the collection ), and define
Set
Then for all :
Theorem 3.2 (Uniform bound over bins). Let the assumptions of Theorem 3.1 hold. Then:
In the segmentation setting we apply Definitions 1.1-1.2 pixel-wise, replacing and by the per-pixel quantities and , so that the guarantee is required to hold at an arbitrary fixed pixel . This is the natural scope for our binning-based calibrator, which acts on each pixel independently. However, to connect Theorems 3.1–3.2 to this notion, observe that for a variable , conditioning on the binning event does not in general coincide with conditioning on : the two agree only when for every . Following Gupta & Ramdas (2021), we resolve this by adding an arbitrarily small uniform perturbation to , e.g. , to obtain a randomized version . The randomized version is practically indistinguishable from the original calibrated predictor but makes the binning scheme recoverable from . The explicit construction is deferred to the proof of Theorem 3.3 and the randomized calibration procedure is summarized in Algorithm 1. We now state the new calibration guarantees:
Theorem 3.3 (Calibration guarantees). Let the assumptions of Theorem 3.1 hold. Let be the randomized calibrator parametrised by , such that . Assume moreover that , , and that, by translation invariance, pixels share the same conditional mean , . Define
Then, is -marginally calibrated for every and every :
Moreover is -conditionally calibrated for every :
The assumption , states that, once the bin assignment at pixel is known, the bin assignments at all other pixels provide no additional information about the label . Notice that the pre-trained network is itself designed to aggregate neighborhood context into the prediction , so the bin assignment at already inherits this spatial information. Crucially, the assumption does not make the problem trivial—the Bernoulli labels remain dependent across pixels, which is why the spatial concentration inequality is needed for our argument. We acknowledge, however, that this conditional independence assumption may be too strong in some settings, and we discuss this aspect further in Appendix F.
Algorithm 1 Calibration algorithm
Input: number of bins , pre-trained predictor , dataset , randomization parameter (set for calibrator of Subsection 3.2, for the randomized version 3.3)
Output: calibrated predictor
1: Partition the dataset into and // Binning scheme: uniform-mass binning via quantiles on
2: Collect the pool of predicted confidences
3: for do
4:
empirical -th quantile
5: , for , // Calibrator: empirical label frequency per bin on
6: for and do
7:
assign pixels to bins
8: for do
9:
10:
empirical positive-class frequency
11:
used only when
12: return
4 Estimation of Theoretical Bound
Since the bound is not analytically tractable, due to the matrix , we estimate it empirically. While this does not yield a closed-form guarantee, it provides a principled, quantitative basis for evaluating the binning method and guiding its application in the segmentation setting. Let be a finite rectangular image domain with pixel alphabet , so configurations are elements of . We fix an arbitrary ordering of the pixels, and we write for the configuration on . Following (Chazottes et al., 2007, Eq. 4), and using the total-variation formulation of (Samson, 2000, Eq. 2.1), we define the matrix with entries indexed by pairs with as
and for all other pairs. This formulation is obtained by choosing the Hamming metric in the definition of (Chazottes et al., 2007, Eq. 4) and is equivalent to the coupling matrices defined in Kontorovich & Ramanan (2008, Eq. 1.2) and Samson (2000, Eq. 2.1). In our application, is the vector of labels restricted to the pixels that are contained in a fixed partition , i.e., . Moreover, as detailed in Section 3, the variables are conditioned on the binning event and therefore on . Adapting equation 9 to this conditional process and taking the 'worst' configuration to remove the dependence, the coupling matrix that enters Theorem 3.2 becomes
since for a binary alphabet the total-variation distance equals the absolute difference of the Bernoulli means.
We estimate the conditional probabilities appearing in equation 10 by fitting an autoregressive model that takes as input and a partition for a fixed bin , and predicts the distribution of the labels . To this aim, we model the joint distribution of the binary segmentation mask restricted to the partition and conditioned to via the autoregressive factorisation
Each conditional is the sigmoid output of a lightweight network trained by maximising the log-likelihood in equation 11 for a set of bins , partitions and . Given the fitted model, the entries of , defined in equation 10, are evaluated for each pair with by computing
Because the conditional is a marginal over the intermediate sites , we estimate it using Monte Carlo iterations. Finally, we estimate by sampling a set of random pasts and taking the configuration correspondent to the largest , obtaining . We compute over a range of positions and and empirically observe in Fig. 1 that its entries depend only on the Euclidean distance . This indicates that is translation-invariant and depends solely on the relative displacement between positions. Therefore, we model the distance dependence using a stretched exponential decay function,
whose fitted parameters provide a closed-form estimate of the full coupling matrix and can be used to compute the coefficients and that appear in Theorem 2.2. Fig. 1 shows the estimated and its exponential fit for a selection of the datasets used in the experiments. See Appendix D for further details.
5 Experiments
We now show that our theoretically derived bound is consistent with the empirical behavior and compare the binning approach with alternative post-hoc calibration methods. To do so we compare the true validity curves

Figure 1: Decay fit for different datasets.
and the empirical ones both for marginal and conditional calibration. Marginal and conditional validity curves are defined as (Gupta & Ramdas, 2021):
and are bounded by Theorem 3.3. Let the ground-truth observed frequency,
Then the empirical validity curves can be approximated as
Both marginal and conditional calibration are estimated as the mean across 5 random calibration and test splits. The error bars in Figure 2 refer to standard deviation across those random splits.
Baselines and Datasets We compare our method with six post-hoc calibration baselines. Temperature Scaling (Guo et al., 2017) rescales the network logits by a single learned scalar T > 0. Logistic Scaling (Platt et al., 1999) fits a logistic function on top of the network outputs, learning an affine transformation of the logits to map them to calibrated probabilities. Meta-Cal (Ma & Blaschko, 2021) first learns a ranking function to categorize calibration samples in two groups, then applies temperature scaling to one group and sets the other as random predictions. Selective Scaling Wang et al. (2023) is an extension of Meta-cal where a binary classifier categorizes pixels in two groups scaled with two different temperatures and . Beta Calibration (Kull et al., 2017) fits a parametric map based on the Beta distribution family, learning three parameters that control the shape and shift of the probability correction. Isotonic Regression (Zadrozny & Elkan, 2002) is a non-parametric method that fits a monotone piecewise-constant mapping via the pool-adjacent-violators algorithm. In Appendix B, we provide further details on these baseline approaches, along with a discussion of the effect of post-hoc calibration on segmentation accuracy (e.g., DICE score).
To assess the generality of our approach, we evaluate all methods across nine segmentation datasets spanning diverse imaging domains and anatomical structures: ISIC (Gutman et al., 2016), Kvasir (Pogorelov et al., 2017), TN3K (Gong et al., 2023), BUSI (Tasnim & Hasan, 2024; Al-Dhabyani et al., 2020), Cityscapes (Cordts et al., 2015; 2016), FLAIR1 (Garioud et al., 2022), Oxford-IIIT Pet (Parkhi et al., 2012), and two subsets of the COCO dataset (Lin et al., 2014). Where datasets provided multi-class annotations, predictions were binarized by collapsing all foreground classes into a single positive class. The diversity of modalities, domains, and backbone architectures — spanning both medical and non-medical imaging and detailed in Appendix C — tests our method across highly heterogeneous conditions, providing a broad basis for evaluating its generality and robustness.
Results We now compare, and show in Figure 2, the empirical validity curves of the binning strategy, and of the other baselines, with our theoretical bound, as well as with the i.i.d. bound that would apply under the (hypothetical) assumption that all pixels are independent. Our experiments highlight two main findings. (1) The empirical validity curves of the binning method, evaluated across several datasets, are consistent with our theoretical bound. As expected, marginal calibration is easier to satisfy: the binning curve shows good calibration properties, i.e. it attains small calibration errors even for small , and the bound consistently controls the binning curve across the experiments. In some cases, the empirical curve approaches the i.i.d. curve, which can be attributed to an intrinsically good calibration of the pre-trained model. Conditional calibration, by contrast, is generally more difficult to achieve. Nevertheless, our derivation yields a meaningful and nontrivial bound that is closely tracked by the binning validity curves. The i.i.d curve further confirms that the independence assumption is too strong for calibrating segmentation models, and would yield incorrect guarantees. While the theoretical bound is only available in estimated form, these results reinforce the validity of the binning method in this setting and justify our strategy of considering each pixel as a data point. (2) The binning strategy, supported by our theoretical calibration error bound, outperforms the other post-hoc calibration baselines. In the marginal setting, the binning approach achieves superior performance relative to most of the competing approaches. Isotonic regression, beta calibration and logistic scaling exhibit comparable behavior on most datasets. Temperature scaling, selective scaling and meta-cal, by contrast, yields unsatisfactory calibration performance on several datasets. In the conditional setting, the advantage of our method becomes even more pronounced. Specifically, the binning approach is the only method capable of attaining low calibration error (<0.1) with high probability (>90%). Among the baselines in the conditional setting, meta-cal performs best, achieving competitive results on a few datasets, such as Pet and COCO_animals. Furthermore, we observe that increasing the number of bins tends to slightly reduce the performance of the approach. This can be attributed to the fact that, as grows, fewer points fall within each individual bin, leading to less reliable statistics per bin and thus noisier calibration estimates. However, using a larger number of bins also confers the key advantage of more localized and sharper calibration. Ultimately, the optimal number of bins is problem-dependent, and the right balance between statistical reliability and calibration sharpness will vary across applications and datasets. We provide additional experiments in Appendix F.
6 Conclusions and Limitations
Motivated by the need for calibration guarantees in the context of segmentation, we investigated this problem and obtained the following results. (1) We derived an improved theoretical bound for segmentation-like data using concentration inequalities. Specifically, we model the segmentation task as a Bernoulli random field, explicitly incorporating the variance into the bound, which leads to a tighter guarantee. (2) We revisited the binning approach for binary segmentation calibration, constructing a calibrator that satisfies both marginal and conditional calibration properties, in accordance with the aforementioned theoretical bound. Notably, we formally justified treating each pixel as an individual data point even in the absence of i.i.d. assumptions, showing that this choice not only admits rigorous guarantees but also proves effective in practice. In fact, the binning approach consistently achieves superior performance compared to the baselines, particularly in the conditional setting, where most alternative baselines fail to reach comparable levels of calibration across the majority of datasets.
The primary limitations of the present work are as follows. First, our analysis is restricted to binary segmentation; an important direction for future research is the extension of the theoretical framework to multi-class segmentation. Second, while our theoretical justification for a binning approach in the segmentation setting remains valid and supported by the experiments, the bound requires empirical estimation, meaning that the guarantee is evaluated approximately rather than exactly. Moreover, deriving the final bound requires taking the supremum over configurations for both and the variance , which is potentially loose. Although our experiments show that, in general, the resulting bounds remain useful and tight, developing more refined and efficient strategies to sharpen them is a promising direction for future work. Finally, we are providing pixel-wise guarantees; a natural question is whether it is possible to bound the calibration error conditioned on specific regions of the image.

Figure 2: Comparisons of validity curves , (in red) and empirical ones , across methods and datasets.
Acknowledgement
This research was funded in whole or in part by the Austrian Science Fund (FWF) 10.55776/PIN2770025 and by the BioTechMed-Graz Young Research Group Grant CICLOPS.
References
Walid Al-Dhabyani, Mohammed Gomaa, Hussien Khaled, and Aly Fahmy. Dataset of breast ultrasound images. Data in brief, 28:104863, 2020.
Kazuoki Azuma. Weighted sums of certain dependent random variables. Tohoku Mathematical Journal, Second Series, 19(3):357–367, 1967.
Theodore Barfoot, Luis C Garcia Peraza Herrera, Ben Glocker, and Tom Vercauteren. Average Calibration Error: A Differentiable Loss for Improved Reliability in Image Segmentation. In International Conference on Medical Image Computing and Computer-Assisted Intervention, pp. 139–149. Springer, 2024.
Theodore Barfoot, Luis C Garcia-Peraza-Herrera, Samet Akcay, Ben Glocker, and Tom Vercauteren. Average Calibration Losses for Reliable Uncertainty in Medical Image Segmentation. IEEE Transactions on Medical Imaging, 2026.
Jacqueline Isabel Bereska, Hamed Karimi, and Reza Samavi. SACP: Spatially-Adaptive Conformal Prediction in Uncertainty Quantification of Medical Image Segmentation. In Medical Imaging with Deep Learning, 2025.
Ondrej Bohdal, Yongxin Yang, and Timothy Hospedales. Meta-Calibration: Learning of Model Calibration Using Differentiable Expected Calibration Error. Transactions on Machine Learning Research, 2023. ISSN 2835-8856.
Stéphane Boucheron, Gábor Lugosi, and Pascal Massart. Concentration Inequalities: A Nonasymptotic Theory of Independence. Oxford University Press, 02 2013. ISBN 9780199535255.
Joren Brunekreef, Eric Marcus, Ray Sheombarsing, Jan-Jakob Sonke, and Jonas Teuwen. Kandinsky Conformal Prediction: Efficient Calibration of Image Segmentation Algorithms. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4135–4143, 2024.
J-R Chazottes, Pierre Collet, Christof Külske, and Frank Redig. Concentration inequalities for random fields via coupling. Probability Theory and Related Fields, 137(1):201–225, 2007.
Jean-René Chazottes et al. Finitary Coding and Gaussian Concentration for Random Fields. arXiv preprint arXiv:2602.14618, 2026.
Liang-Chieh Chen, George Papandreou, Florian Schroff, and Hartwig Adam. Rethinking Atrous Convolution for Semantic Image Segmentation. arXiv preprint arXiv:1706.05587, 2017.
Liang-Chieh Chen, Yukun Zhu, George Papandreou, Florian Schroff, and Hartwig Adam. Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 801–818, 2018.
Marius Cordts, Mohamed Omran, Sebastian Ramos, Timo Scharwächter, Markus Enzweiler, Rodrigo Benenson, Uwe Franke, Stefan Roth, and Bernt Schiele. The Cityscapes Dataset. In CVPR Workshop on The Future of Datasets in Vision, 2015.
Marius Cordts, Mohamed Omran, Sebastian Ramos, Timo Rehfeld, Markus Enzweiler, Rodrigo Benenson, Uwe Franke, Stefan Roth, and Bernt Schiele. The Cityscapes Dataset for Semantic Urban Scene Understanding. In Proc. of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
A Philip Dawid. The Well-Calibrated Bayesian. Journal of the American statistical Association, 77(379): 605–610, 1982.
Zhipeng Ding, Xu Han, Peirong Liu, and Marc Niethammer. Local Temperature Scaling for Probability Calibration. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 6889–6899, 2021.
David A Freedman. On tail probabilities for martingales. the Annals of Probability, pp. 100–118, 1975.
Yarin Gal and Zoubin Ghahramani. Dropout as a Bayesian Approximation: Representing Model Uncertainty in Deep Learning. In International Conference on Machine Learning, pp. 1050–1059. PMLR, 2016.
Anatol Garioud, Stéphane Peillet, Eva Bookjans, Sébastien Giordano, and Boris Wattrelos. FLAIR #1: semantic segmentation and domain adaptation dataset. 2022. doi: 10.13140/RG.2.2.30183.73128/1.
Josselin Garnier and Xavier Langhendries. Concentration Inequalities for Non-causal Random Fields. Electronic Journal of Statistics, 16:1–44, 2022.
Paul Glasserman. Monte Carlo Methods in Financial Engineering, volume 53. Springer, 2004.
Haifan Gong, Jiaxin Chen, Guanqi Chen, Haofeng Li, Guanbin Li, and Fei Chen. Thyroid region prior guided attention for ultrasound segmentation of thyroid nodules. Computers in Biology and Medicine, 155:106389, 2023. ISSN 0010-4825.
Chuan Guo, Geoff Pleiss, Yu Sun, and Kilian Q Weinberger. On Calibration of Modern Neural Networks. In International Conference on Machine Learning, pp. 1321–1330. PMLR, 2017.
Chirag Gupta and Aaditya Ramdas. Distribution-free calibration guarantees for histogram binning without sample splitting. In International Conference on Machine Learning, pp. 3942–3952. PMLR, 2021.
Chirag Gupta, Aleksandr Podkopaev, and Aaditya Ramdas. Distribution-free binary classification: prediction sets, confidence intervals and calibration. Advances in Neural Information Processing Systems, 33: 3711–3723, 2020.
David Gutman, Noel CF Codella, Emre Celebi, Brian Helba, Michael Marchetti, Nabin Mishra, and Allan Halpern. Skin lesion analysis toward melanoma detection: A challenge at the international symposium on biomedical imaging (ISBI) 2016, hosted by the international skin imaging collaboration (ISIC). arXiv preprint arXiv:1605.01397, 2016.
Ramya Hebbalaguppe, Jatin Prakash, Neelabh Madan, and Chetan Arora. A Stitch in Time Saves Nine: A Train-Time Regularizing Loss for Improved Neural Network Calibration. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16081–16090, 2022.
Wassily Hoeffding. Probability Inequalities for Sums of Bounded Random Variables. Journal of the American Statistical Association, 58(301):13–30, 1963. ISSN 01621459, 1537274X.
Alex Kendall and Yarin Gal. What Uncertainties Do We Need in Bayesian Deep Learning for Computer Vision? Advances in Neural Information Processing Systems, 30, 2017.
Leonid Kontorovich and Kavita Ramanan. Concentration inequalities for dependent random variables via the martingale method. 2008.
Meelis Kull, Telmo Silva Filho, and Peter Flach. Beta calibration: a well-founded and easily implemented improvement on logistic calibration for binary classifiers. In Artificial Intelligence and Statistics (AISTATS), pp. 623–631. PMLR, 2017.
Meelis Kull, Miquel Perello Nieto, Markus Kängsepp, Telmo Silva Filho, Hao Song, and Peter Flach. Beyond temperature scaling: Obtaining well-calibrated multi-class probabilities with Dirichlet calibration. Advances in Neural Information Processing Systems, 32, 2019.
Aviral Kumar, Sunita Sarawagi, and Ujjwal Jain. Trainable Calibration Measures For Neural Networks From Kernel Mean Embeddings. In International Conference on Machine Learning, pp. 2805–2814. PMLR, 2018.
Fabian Küppers, Anselm Haselhoff, Jan Kronenberger, and Jonas Schneider. Confidence Calibration for Object Detection and Segmentation. In Deep Neural Networks and Data for Automated Driving: Robustness, Uncertainty Quantification, and Insights Towards Safety, pp. 225–250. Springer, 2022.
Balaji Lakshminarayanan, Alexander Pritzel, and Charles Blundell. Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles. Advances in Neural Information Processing Systems, 30, 2017.
Stan Z. Li. Markov Random Field Modeling in Image Analysis. Springer, 3rd edition, 2009.
Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft COCO: Common Objects in Context. In Computer Vision–ECCV 2014: 13th European conference, zurich, Switzerland, September 6-12, 2014, proceedings, part v 13, pp. 740–755. Springer, 2014.
Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollár. Focal Loss for Dense Object Detection. In Proceedings of the IEEE International Conference on Computer Vision, pp. 2980–2988, 2017.
Torgny Lindvall. Lectures on the coupling method. Courier Corporation, 2002.
Kangdao Liu, Tianhao Sun, Hao Zeng, Yongshan Zhang, Chi-Man Pun, and Chi-Man Vong. Spatial-Aware Conformal Prediction for Trustworthy Hyperspectral Image Classification. IEEE Transactions on Circuits and Systems for Video Technology, 2025.
Xingchen Ma and Matthew B Blaschko. Meta-Cal: Well-controlled post-hoc calibration by ranking. In International Conference on Machine Learning, pp. 7235–7245. PMLR, 2021.
Katalin Marton. Measure Concentration for a Class of Random Processes. Probability Theory and Related Fields, 110:427–439, 1998.
Katalin Marton. Measure Concentration and Strong Mixing. Studia Scientiarum Mathematicarum Hungarica, 40:95–113, 2003.
Colin McDiarmid et al. On the method of bounded differences. Surveys in combinatorics, 141(1):148–188, 1989.
Alireza Mehrtash, William M Wells, Clare M Tempany, Purang Abolmaesumi, and Tina Kapur. Confidence Calibration and Predictive Uncertainty Estimation for Deep Medical Image Segmentation. IEEE Transactions on Medical Imaging, 39(12):3868–3878, 2020.
Shakir Mohamed, Mihaela Rosca, Michael Figurnov, and Andriy Mnih. Monte Carlo Gradient Estimation in Machine Learning. Journal of Machine Learning Research, 21(132):1–62, 2020.
Mehryar Mohri and Afshin Rostamizadeh. Stability Bounds for Stationary -mixing and -mixing Processes. Journal of Machine Learning Research, 11(2), 2010.
Luca Mossina and Corentin Friedrich. Conformal Prediction for Image Segmentation Using Morphological Prediction Sets. In International Conference on Medical Image Computing and Computer-Assisted Intervention, pp. 78–88. Springer, 2025.
Jishnu Mukhoti, Viveka Kulharia, Amartya Sanyal, Stuart Golodetz, Philip Torr, and Puneet Dokania. Calibrating Deep Neural Networks using Focal Loss. Advances in Neural Information Processing Systems, 33:15288–15299, 2020.
Rafael Müller, Simon Kornblith, and Geoffrey E Hinton. When Does Label Smoothing Help? Advances in Neural Information Processing Systems, 32, 2019.
Balamurali Murugesan, Sukesh Adiga Vasudeva, Bingyuan Liu, Herve Lombaert, Ismail Ben Ayed, and Jose Dolz. Trust your neighbours: Penalty-based constraints for model calibration. In International Conference on Medical Image Computing and Computer-Assisted Intervention, pp. 572–581. Springer, 2023.
Balamurali Murugesan, Sukesh Adiga Vasudeva, Bingyuan Liu, Herve Lombaert, Ismail Ben Ayed, and Jose Dolz. Neighbor-Aware Calibration of Segmentation Networks with Penalty-Based Constraints. Medical Image Analysis, 101:103501, 2025.
Yaniv Ovadia, Emily Fertig, Jie Ren, Zachary Nado, David Sculley, Sebastian Nowozin, Joshua Dillon, Balaji Lakshminarayanan, and Jasper Snoek. Can You Trust Your Model's Uncertainty? Evaluating Predictive Uncertainty Under Dataset Shift. Advances in Neural Information Processing Systems, 32, 2019.
Omkar M. Parkhi, Andrea Vedaldi, Andrew Zisserman, and C. V. Jawahar. Cats and Dogs. In IEEE Conference on Computer Vision and Pattern Recognition, 2012.
John Platt et al. Probabilistic Outputs for Support Vector Machines and Comparisons to Regularized Likelihood Methods. Advances in Large Margin Classifiers, 10(3):61–74, 1999.
Konstantin Pogorelov, Kristin Ranheim Randel, Carsten Griwodz, Sigrun Losada Eskeland, Thomas de Lange, Dag Johansen, Concetto Spampinato, Duc-Tien Dang-Nguyen, Mathias Lux, Peter Thelin Schmidt, Michael Riegler, and Pål Halvorsen. KVASIR: A Multi-Class Image Dataset for Computer Aided Gastrointestinal Disease Detection. In Proceedings of the 8th ACM on Multimedia Systems Conference, MMSys'17, pp. 164–169, New York, NY, USA, 2017. ACM. ISBN 978-1-4503-5002-0. doi: 10.1145/3083187.3083212.
Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-Net: Convolutional Networks for Biomedical Image Segmentation. In International Conference on Medical Image Computing and Computer-Assisted Intervention, pp. 234–241. Springer, 2015.
Axel-Jan Rousseau, Thijs Becker, Simon Appeltans, Matthew Blaschko, and Dirk Valkenborg. Post hoc calibration of medical segmentation models. Discover Applied Sciences, 7(3):180, 2025.
Paul-Marie Samson. Concentration of Measure Inequalities for Markov Chains and -mixing Processes. The Annals of Probability, 28:416–461, 2000.
Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the Inception Architecture for Computer Vision. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2818–2826, 2016.
Jarin Tasnim and Md Kamrul Hasan. CAM-QUS guided self-tuning modular CNNs with multi-loss functions for fully automated breast lesion classification in ultrasound images. Physics in Medicine & Biology, 69(1):015018, 2024.
Jiaye Teng, Chuan Wen, Dinghuai Zhang, Yoshua Bengio, Yang Gao, and Yang Yuan. Predictive Inference with Feature Conformal Prediction. In The Eleventh International Conference on Learning Representations, 2023.
Aaron Van Den Oord, Nal Kalchbrenner, Lasse Espeholt, Oriol Vinyals, Alex Graves, et al. Conditional Image Generation with PixelCNN Decoders. Advances in Neural Information Processing Systems, 29, 2016a.
Aäron Van Den Oord, Nal Kalchbrenner, and Koray Kavukcuoglu. Pixel Recurrent Neural Networks. In International Conference on Machine Learning, pp. 1747–1756. PMLR, 2016b.
Bruno Viti, Elias Karabelas, and Martin Holler. CONSIGN: Conformal Segmentation Informed by Spatial Groupings via Decomposition. In The Fourteenth International Conference on Learning Representations, 2026.
Vladimir Vovk, Alexander Gammerman, and Glenn Shafer. Algorithmic Learning in a Random World. Springer, 2005.
Dongdong Wang, Boqing Gong, and Liqiang Wang. On calibrating semantic segmentation models: Analyses and an algorithm. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 23652–23662, 2023.
HuaJun Xi, Jianguo Huang, Kangdao Liu, Lei Feng, and Hongxin Wei. Does confidence calibration improve conformal prediction? Transactions on Machine Learning Research, 2025. ISSN 2835-8856.
Bin Yu. Rates of convergence for empirical processes of stationary mixing sequences. The Annals of Probability, pp. 94–116, 1994.
Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun, Junsuk Choe, and Youngjoon Yoo. CutMix: Regularization strategy to train strong classifiers with localizable features. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 6023–6032, 2019.
Bianca Zadrozny and Charles Elkan. Obtaining calibrated probability estimates from decision trees and naive Bayesian classifiers. In ICML, pp. 2001, 2001.
Bianca Zadrozny and Charles Elkan. Transforming Classifier Scores into Accurate Multiclass Probability Estimates. In Proceedings of the eighth ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 694–699, 2002.
Hongyi Zhang, Moustapha Cisse, Yann N. Dauphin, and David Lopez-Paz. mixup: Beyond Empirical Risk Minimization. In International Conference on Learning Representations, 2018.
Kato Zoltan and Zerubia Josiane. Markov random fields in image segmentation. Foundations and Trends in Signal Processing, 5(1-2):1–155, 2012.
A Proofs
A.1 Derivation of the martingale increment identity
For a Bernoulli alphabet , the martingale increment, using the law of total expectation, reduces to:
Both cases are captured by the identity of equation 2.
A.2 Proof of Lemma 2.1
Proof. We first notice that if both sides equal zero and the bound holds trivially. In the general case, fix and recall , are -measurable. Given , is a centered two-point random variable with:
Apply Theorem 2.9 of (Boucheron et al., 2013) with , , , and parameter in place of :
Since , this is exactly equation 3. We use rather than the tighter to keep the bound symmetric in .
A.3 Derivation of the bound
By Chazottes et al. (2007, Eq. 5), , where the matrix-vector product is
Since for all j equation 4, this simplifies to
where denotes the -th row sum of . Taking the supremum over all configurations and setting yields
A.4 Proof of Theorem 2.2
Proof. From equation 1 and equation 2 we have that:
where both , are -measurable. We apply the exponential Chebyshev inequality, and obtain that for any :
Focusing on the expectation, we peel off one term using the tower property:
Now we apply Lemma 2.1 to bound . Notice that defined in equation 4 is increasing in , therefore and Lemma 2.1 can be applied. More generally, for the conditional MGF of any increment , Lemma 2.1 gives . The bounding factor is itself a random variable, since and are -measurable; consequently it cannot be factored out of the successive conditioning. We remove this randomness in two steps, before peeling off the terms.
First, we bound the increment. For we have for all , so equation 5 yields the deterministic bound . Since is increasing on and , conditionally on ,
so that the argument of is now the deterministic quantity .
Second, we remove the conditional variance using the same strategy applied to the coupling matrix . Since by definition of and ,
The right-hand side is now a deterministic constant, so it factors cleanly out of each conditional expectation. Peeling the n terms one at a time yields
It is possible to show, using Taylor expansions, that for , the inequality
holds. Restricting to we ensure for all . We apply equation 17 with :
Now, we bound the denominator uniformly by its worst case, , and obtain:
with and as defined in equation 6. (This is the sub-gamma form of Boucheron et al. (2013, Section 2.4).) We plug in equation 18 in equation 15 and obtain:
In order to make the right-hand side minimal, we derive by and obtain:
Setting the derivative to zero gives a quadratic equation in , selecting the that satisfies gives us:
By substituting in equation 19 we get the following bound:
The two-sided bound equation 7 follows selecting -g. In this case, -g is decreasing in , therefore has to be defined as . Notice that using -g swaps and but leaves S and c unchanged since is symmetric.
A.5 Extension of Theorem 2.2 to
To extend Theorem 2.2 to we follow the same strategy of (Chazottes et al., 2007, Section 2.4). Let and . Introduce any enumeration . We use the notation , which is the equivalent of in the case of Theorem 2.2. Therefore, denotes the sigma-field generated by and is the trivial sigma-field. Analogously to equation 1 we have the following decomposition:
Finally we introduce the coupling matrices as
where denotes the maximal coupling between the conditional measures and .
Theorem A.1 (Improved concentration for Bernoulli mean in ). Let and let . Define as in equation 21, , and with . Set
Then for all :
Proof. The enumeration maps the indices of to . Therefore, we can apply the proof of Theorem 2.2 and obtain the bound equation 23.
A.6 Proofs of Calibration Theorems
Proof of Theorem 3.1. Fix a bin . The observed frequency can be written as
which has the form , i.e. the empirical mean of Bernoulli variables indexed over the disjoint domains . Moreover, since the binning event is fixed, is deterministic and the randomness is over the Bernoulli variables.
Since images are drawn independently, pixels from different images are independent. Therefore the coupling matrix of the full collection of pixels is block-diagonal, where each block correspond to the coupling matrix of image conditioned on the binning event (i.e. the collection ). is defined as in Section 2.2 for pixels within the same image , and for pixels from different images. As a consequence, the row sums of the global coupling matrix reduce to the within-image row sums:
since all cross-image terms vanish. The quantities and are computed by substituting into equation 22:
with .
We can now apply Theorem A.1, conditioned on the binning event to fix , with , , :
Marginalising over all the binning events we get
Proof of Theorem 3.2. By a union bound over the bins:
Proof of Theorem 3.3. Marginal calibration. We start by noticing that conditioning on the event, , is not equivalent to conditioning on the event . The two events coincide only if . In that case knowing that pixel has an associated calibrated predictor , and therefore , automatically tells that , since is different for each bin . As introduced in Gupta & Ramdas (2021), a simple trick to not lose the informativeness of is to randomise it with an arbitrary small value. More formally, define the new calibrated predictor as
where is an arbitrary parameter. If we choose, for example, , then the new randomized calibrated predictor is in practice indistinguishable from the old one, but, we can now write that . In the following, we denote as the union of all of the pixel-wise events .
We proceed by computing the conditional expected value of as
Since the derivation holds for each bin , we drop the notation and we continue for a generic pixel . Substituting in Theorem 3.1 we obtain:
We notice that by definition, for a fixed bin , and therefore
Using the triangle inequality and the definition of we get
We proceed by noticing that
and therefore
Taking the complement we obtain the final result
Conditional calibration. If we take the complement of Theorem 3.2 we obtain
Moreover, by the same argument as in the marginal case
After the randomization introduced above, the values are pairwise distinct almost surely, so the range of coincides with and to each in this range corresponds a unique bin with . Then
B Baseline Methods
We now describe the baseline methods. For all the post-hoc baselines (and our method), the spatial predictions (e.g. softmax and logits maps of shape ) are flattened before fitting, and each pixel is treated independently from the others.
B.1 Temperature Scaling
Temperature Scaling (Guo et al., 2017) is the simplest post-hoc calibration scheme. Given raw logits produced by the network, the calibrated probability vector is
where T > 0 is a single scalar temperature shared across all classes and all samples. For binary classification, equation 24 reduces to
where is the sigmoid function and is the scalar logit. is found by minimizing the cross-entropy on the calibration set:
In practice, over-confident networks yield , which softens the output distribution toward uniform. In the experiments, the temperature is log-parametrized as with , ensuring positivity throughout optimization without any explicit constraint. The single parameter is optimized with L-BFGS using a strong Wolfe line search.
B.2 Logistic scaling
Logistic scaling (Platt et al., 1999) (also known as Platt scaling) learns an affine transformation of the raw logits followed by a sigmoid, producing calibrated probabilities via the map
where is the pre-sigmoid logit, is a scale parameter, and is a bias term.
Logistic scaling generalises Temperature Scaling, which corresponds to the special case and . Conversely, it is a special case of Beta Calibration (Kull et al., 2019), which uses the richer map with independent parameters for and .
Given calibration pairs with , the parameters are found by minimising the binary cross-entropy:
In the experiments, the positivity constraint on is enforced via a log-parameterisation , , and the two-parameter problem is solved with L-BFGS.
B.3 Beta Calibration
Beta Calibration (Kull et al., 2019) generalizes logistic (Platt) scaling for binary classifiers by exploiting the Beta family of distributions. The calibration map is
where are shape parameters and is a bias. Equation 29 can be derived as the ratio of two Beta densities evaluated at . The three-parameter family subsumes temperature scaling () and Platt scaling ( free) as special cases, providing strictly greater expressiveness. The parameters are optimized by minimizing binary cross-entropy on the calibration set:
In the experiments, the positivity constraints on and are handled via log-parametrization (, ), reducing the constrained problem to an unconstrained three-parameter optimization over . L-BFGS with a strong Wolfe line search is used.
B.4 Isotonic Regression Calibration
Isotonic Regression Calibration (Zadrozny & Elkan, 2002) learns a non-parametric, piecewise-constant monotone mapping
from raw confidence scores to calibrated probabilities. Given calibration pairs with and , isotonic regression solves
via the pool adjacent violators (PAV) algorithm. Unlike Temperature Scaling and Beta Calibration, Isotonic Regression places no parametric assumptions on the shape of the miscalibration, making it more flexible but also more prone to overfitting on small calibration sets.
In the experiments, we use SCIKIT-LEARN's IsotonicRegression with out_of_bounds="clip", which fits a piecewise-constant, non-decreasing mapping on the flattened validation scores via the pool adjacent violators algorithm. At inference, the fitted mapping is applied element-wise, with input values outside the training range clipped to the nearest boundary.
B.5 Meta-cal
Meta-cal (Ma & Blaschko, 2021) is a post-hoc calibration method that combines temperature scaling with a confidence-aware sample selection strategy. The key idea is to avoid calibrating high-uncertainty predictions—which are unreliable by nature—and instead assign them the uninformative probability 0.5.
Step 1 – Entropy-based partitioning For each pixel with pre-sigmoid logit , the binary entropy of the uncalibrated prediction is computed as
A threshold on this entropy separates the predictions into a low-entropy set and a high-entropy set .
Step 2 – Threshold selection The threshold is chosen to match a target coverage accuracy . A small held-out (10%) of the calibration data is binned by entropy quantiles, and for each bin the cumulative accuracy is computed. Isotonic regression (decreasing) is then fitted on the (cumulative accuracy, mean entropy) pairs; the threshold is obtained by evaluating the isotonic fit at the target accuracy:
Step 3 – Temperature scaling on low-entropy samples. On the remaining calibration data, only samples in are used to fit a single temperature parameter by minimising binary cross-entropy:
Step 4 – Inference At test time, the calibrated probability is
By abstaining from calibrating high-entropy pixels, MetaCal avoids distorting predictions where the model is genuinely uncertain, which can improve calibration compared to global temperature scaling. In the experiments .
B.6 Selective Scaling
Selective Scaling (Wang et al., 2023) extends Meta-cal by learning two temperatures and a binary selector that routes each prediction to the appropriate one. The key observation is that correctly classified and misclassified pixels benefit from different degrees of rescaling.
Step 1 – Selector. A small MLP is trained on 10% of the calibration split to predict whether the network's hard prediction matches the ground-truth . Its input is the uncalibrated probability and its binary target is . After training, the selector partitions any set of pixels into two groups:
Step 2 – Two temperatures. On the rest of the calibration split, two scalar temperatures (for predicted-incorrect pixels ) and (for predicted-correct pixels ) are jointly optimised by minimising the total cross-entropy:
As in Temperature Scaling, both temperatures are log-parametrised to ensure strict positivity, and the two-parameter problem is solved with L-BFGS.
Step 3 – Inference. At test time, the calibrated probability of a new pixel with logit z is
In practice, over-confident networks typically yield (softening wrong predictions) and (sharpening correct ones), producing a more reliable confidence signal than a single global temperature.
B.7 Effect of Calibration on Accuracy
While the main objective of the paper is to compare the calibration performances of different methods, it is natural to ask what is the effect of these calibration methods on the accuracy of the underlying segmentation model. To do that we are going to evaluate the DICE score difference, before and after calibration, on the datasets used in the experiments. The DICE score is defined as:
where Y and are the ground-truth and predicted segmentation respectively. The mean is evaluated across random calibration/test splits. Tables 1–2 show that post-hoc calibration methods yield, on average, a
Table 1: Relative DICE score variation after calibration.
| Methods | Cityscapes | COCO-an. | COCO-veh. | TN3K |
|---|---|---|---|---|
| Beta-cal | 2.30% | 0.22% | 0.33% | 0.05% |
| Iso.Regr. | 1.55% | 0.36% | 0.32% | -0.55% |
| Meta-cal | -33.59% | -14.04% | -8.28% | -53.04% |
| Logistic | 2.6% | 0.36% | 0.33% | -0.02% |
| Binning (B=10) | -1.51% | 0.05% | -0.07% | -3.43% |
| Binning (B=30) | 1.49% | 0.36% | 0.22% | -14.2% |
Table 2: Relative DICE score variation after calibration.
| Methods | ISIC | Kvasir | BUSI | FLAIR1 | Pet |
|---|---|---|---|---|---|
| Beta-cal | -0.86% | -0.33% | 7.11% | -0.91% | -0.01% |
| Iso.Regr. | -0.19% | -0.75% | 8.31% | -0.56% | -0.01% |
| Meta-cal | -26.30% | -43.60% | -0.37% | -2.89% | -30.63% |
| Logistic | -0.41% | -0.07% | 4.21% | -3.34% | -0.04% |
| Binning (B=10) | -0.33% | -9.11% | 2.56% | -0.20% | -0.53% |
| Binning (B=30) | -0.49% | -0.87% | 3.84% | -0.67% | -0.38% |
marginal decrease in segmentation accuracy on the order of a tenth of a percentage point. There are some exceptions, such as Cityscapes or BUSI, where the calibration brings also an improvement in the accuracy. Meta-cal is the worst method concerning the effect on DICE, often substantially decreasing the accuracy. Moreover, we observe that a larger number of bins is generally preferable: too few bins produce overly coarse intervals, increasing the risk of incorrectly reassigning the confidence values of individual pixels. Temperature scaling and Selective scaling do not change the accuracy of the model, hence are not discussed.
C Datasets and Pre-trained Models
C.1 Datasets
Cityscapes (Cordts et al., 2016; 2015) is a large-scale benchmark for semantic understanding of urban street scenes, collected from a moving vehicle across 50 cities under varying seasonal and lighting conditions. It provides 5,000 images with high-quality pixel-level annotations and an additional 20,000 coarsely annotated frames. The fine-annotation split is pre-divided into 2,975 training, 500 validation, and 1,525 test images at a resolution of 1024×2048 pixels. Annotations span 30 semantic classes organized into 8 higher-level categories, covering both static elements (road, building, vegetation) and dynamic actors (person, car, cyclist). Its combination of high resolution, class diversity, and instance-level masks has made it the de-facto benchmark for segmentation in autonomous driving.
MS COCO (Lin et al., 2014) (Common Objects in Context) is a large-scale, general-purpose dataset for object detection, instance segmentation, and image captioning. It contains over 330,000 images with more than 2.5 million labeled instances drawn from 80 foreground object categories and 91 background 'stuff' categories. Its scale and annotation richness have established COCO as the primary standard for evaluating general-purpose segmentation models. We have created two subsets from the original dataset: COCO- animals and COCO-vehicles. Specifically, we selected images that feature either animals or humans to form the COCO-animals dataset, and images that contain vehicles or humans to create the COCO-vehicles dataset. The COCO-animals dataset includes 314 images with the following labels: background, cat, dog, sheep, cow, horse, bird, and human. In contrast, the COCO-vehicles dataset contains 321 images with these labels: background, train, bus, bicycle, airplane, car, boat, and human. We used those images for the calibration experiments.
TN3K (Gong et al., 2023) The TN3K (Thyroid Nodule Region Segmentation Dataset) comprises 3493 ultrasound images from 2421 patients, captured between January 2016 and August 2020. These images were selected from over 30,000 images provided by different hospitals.
ISIC 2016 (Gutman et al., 2016) is the first public benchmark released by the International Skin Imaging Collaboration (ISIC) for automated skin lesion analysis, hosted as part of the ISBI 2016 challenge. It contains 900 dermoscopic training images and 379 test images, each annotated with a binary pixel-level mask delineating the lesion boundary against the surrounding skin. The classification task is binary (melanoma vs. benign), and the segmentation ground-truth was produced by expert clinicians.
Kvasir-SEG (Pogorelov et al., 2017) is an open-access dataset of 1,000 gastrointestinal polyp images captured during colonoscopy, each paired with a manually delineated binary segmentation mask and a corresponding bounding box annotation. Masks were initially annotated by a medical doctor and then verified by an experienced gastroenterologist, ensuring high ground-truth quality. Accurate polyp segmentation is clinically important because polyps are precursors to colorectal cancer.
BUSI (Tasnim & Hasan, 2024; Al-Dhabyani et al., 2020) is a publicly available collection of breast ultrasound images. It contains 780 images from 600 female patients of age ranging between 25 and 75 years, featuring malignant and benign breast cancers but also normal cases without cancer. The dataset had few anomalies that were later corrected.
FLAIR1 (Garioud et al., 2022) The FLAIR #1 (French Land cover from Aerospace ImageRy) dataset is a large-scale, high-resolution, aerial imagery dataset designed for semantic segmentation of land cover across France. Developed by the French National Institute of Geographical and Forest Information (IGN), it aims to address challenges in domain adaptation, such as environmental heterogeneity and temporal changes. The FLAIR datasets are released under the Open Licence 2.0 from Etalab.
Oxford-IIIT Pet (Parkhi et al., 2012) is a fine-grained recognition and segmentation dataset comprising approximately 7390 images of cats and dogs spanning 37 breeds, with roughly 200 images per class.
C.2 Pre-trained Models and Data Splits
U-Net We train a lightweight U-Net Ronneberger et al. (2015) from scratch for binary foreground segmentation. The encoder follows a standard contracting path with four downsampling stages: starting from a base width , each stage doubles the number of channels (, i.e. up to 512 feature maps at the bottleneck) and halves the spatial resolution via max-pooling. Every resolution level applies two successive convolutions, each followed by batch normalisation and ReLU activation; a spatial dropout layer () is inserted between the two convolutions to regularise training. The decoder mirrors the encoder with four transposed-convolution upsampling steps (, stride 2), each concatenating the corresponding encoder skip connection before applying the same double-convolution block. A final convolution projects the -channel feature map to a single output logit per pixel; the sigmoid activation is applied externally. The model takes 3-channel RGB images of arbitrary spatial resolution as input and produces raw logits of the same spatial size.
This architecture has been used for the following datasets: ISIC 2016, BUSI, Kvasir-SEG and TN3K. Each training has been performed with 200 epochs, batch size of 8 and learning rate of . Images and masks are resized to pixels; images are normalized with ImageNet mean and standard deviation. For ISIC, the dataset is already divided in train/val/test. We use the train and val splits to train the U-Net and the test split, featuring 379 images, for the calibration experiments. For BUSI, we use only the images with foreground (cancer). We train the U-Net with 439 images and use only 150 for the calibration experiments. This dataset is the smallest one in our evaluation and shows that meaningful calibration can be achieved even with few images. For Kvasir, we use 700 images to train the U-Net and the remaining 300 for the calibration experiments. Finally for TN3K, we train the U-Net with 2879 images and used the remaining 614 for the calibration experiments.
Table 3: Comparison of post-hoc calibration baselines.
| Dataset | Pre-trained model | # samples for exp. (cal.+test) |
|---|---|---|
| Cityscapes | DeepLabv3plus_ResNet101 | 500 |
| COCO-animals | DeepLabv3plus_ResNet50 | 314 |
| COCO-vehicles | DeepLabv3plus_MobileNet | 321 |
| TN3K | U-Net | 614 |
| ISIC | U-Net | 379 |
| Kvasir | U-Net | 300 |
| BUSI | U-Net | 150 |
| FLAIR1 | ResNet34-UNet | 500 |
| Oxford-Pet | DeepLabv3_resnet50 + fine tuning | 739 |
DeepLabV3 Fine-tuning For the Oxford-IIIT Pet dataset we fine-tune a deeplabv3_resnet50 model from torchvision.models. The original classifier head (21-class) is replaced by a 1×1 convolutional layer mapping the 256-channel output to 2 classes (foreground / background).
The dataset consists of JPEG images paired with annotations; the annotations are binarized so that label 1 (pet) maps to the foreground class and all other values map to background. Images and masks are resized to 224×224 pixels; images are normalized with ImageNet mean and standard deviation. A 90/10 random split yields training and test subsets. The model is optimized with Adam (lr = 10⁻⁴) using a pixel-wise cross-entropy loss over mini-batches of 32 images for 5 epochs. We use 6651 images for training and obtain the prediction of 739 images for the calibration experiments.
ResNet34-UNet For the FLAIR1 challenge we use a pre-trained model (FLAIR-INC_rgie_15cl_resnet34-unet) provided by the organizer¹. We use the pre-trained model on the smallest test subsets (D022_2021) containing only 500 images, which are later used in our calibration experiments. The predictions contain 19 different classes which are binarized with labels=0, 8, 10, 11, 12, 17 as foreground and the rest as background.
DeepLabV3+ Models For the Cityscapes dataset we use a DeepLabV3Plus-ResNet101² backbone Chen et al. (2018; 2017) on the validation set featuring 500 images. All of the predictions were randomly cropped to 256 × 256 and binarized with labels=11, ..., 18 as foreground and the rest as background. For the COCO-animals experiment we use the DeepLabv3plus_ResNet50 backbone, while for the COCO-vehicles the DeepLabv3plus_MobileNet backbone. All of the predictions were binarized with labels=1, ..., 7 as foreground and the rest as background. The code is published under the MIT License.
Data Splits During the experiments we perform K random splits of the data. For each random split we divide our dataset , in three subsets , and . For the post-hoc baselines, and are used to calibrated the models. For the binning approach, is used to construct the bins, and is used to construct the calibrator .
D Theoretical Bound Estimation
D.1 estimation with autoregressive model
We now go through the implementation of the autoregressive model used to estimate the matrix . The coupling matrix quantifies how much the distribution of changes when is intervened upon, holding the past fixed. Evaluating this quantity requires access to the full conditional distribution , which in turn depends on the joint distribution over the mask. The autoregressive factorisation,
¹https://ignf.github.io/FLAIR/
²https://github.com/VainF/DeepLabV3Plus-Pytorch expresses the conditional as a marginal over the intermediate sites . This marginal is approximated by Monte Carlo. Moreover, since in our application the variable are conditioned on a realization of the binning scheme and since we need to consider only the labels in a specific bin , we construct the autoregressive model such that it takes as input a partition and calibrated predictions , resulting in the factorisation:
where is a binary mask and is a subset of a 2-D grid .
Model architecture To ease the notation we are going to drop the b-dependent notation. We model the per-site conditional as a PixelCNN Van Den Oord et al. (2016b;a)
with sites in raster order, and . The network has two parallel streams: a -stream of causally masked convolutions carrying , and an -stream of convolutions only, carrying . The streams are summed at the readout, so equation 41 depends on and on alone and never on for .
For a kernel of odd size k with center at , the causal masks are
Mask A excludes the center, mask B includes it. A masked convolution multiplies the weight tensor by before convolving: .
The -stream uses mask A in its first layer (so its output at site x does not depend on ) and mask B thereafter (centre allowed because upstream activations are already strictly causal in ):
The -stream has the same skeleton with and no masking: and residual blocks formed analogously from two convolutions and a ReLU.
The readout sums the streams and applies a final pointwise layer:
Coupled sampling Concretely, we estimate by sampling with a common-random-numbers coupling (Mohamed et al., 2020; Glasserman, 2004). Fix a context , then for each Monte Carlo trial we run two chains A and B:
For each subsequent site (where are the image dimensions) we perform one batched forward pass to obtain the two conditional probabilities
draw a single threshold shared between the two chains, and set
Each chain therefore advances under its own conditional — so neither estimator is biased — while the shared threshold ensures that sites where the two conditionals agree contribute exactly zero to the difference . Averaged over M trials,
is an unbiased Monte Carlo estimator of conditional on , with variance reduced compared to two independent runs.
Full decay curve A key observation is that the autoregressive structure allows us to estimate for all simultaneously from a single pair of coupled trajectories. The recorded differences at every already provide one Monte Carlo realisation of at every target site. Repeating the coupled run times under the same gives the full empirical decay for .
Aggregation and the decay fit To reduce dependence on any particular grid location, we repeat the procedure for source sites drawn from the interior of the grid, and for test contexts providing different prefixes . For each source-context pair we compute the per-target estimates as described above and bin them by Euclidean distance . The aggregation across the three nested sources of randomness — trials, contexts, sources — is performed as follows:
-
Within each , the Monte Carlo trials are averaged .
-
For each context, we average the per-target values over all falling in the same distance bin , yielding one number per .
-
Across contexts, we take the maximum over . This is a worst-case aggregation: the calibration bound of Theorem 2.2 depends on rather than its average, since the bound must hold for every realisable prefix.
-
Across sources, we average the resulting per-source worst-case values to obtain the empirical decay curve .
Fitting the parametric form equation 13 to this curve serves two purposes. First, it provides a closed-form approximation of the coupling matrix for any distance, including distances not directly observed in the finite grid. Second, it allow us to compute the coefficients and of the bounds.
Moreover, since we need to estimate the coupling matrix for variables in bin , we have to use the factorisation in equation 40. In practice, we estimate the matrix for different bins and average the results.
Experiment settings During the experiments we use the calibration dataset to estimate the matrix . We sample random contexts, of shape ( for the FLAIR dataset, due to the larger image dimensions) from the ground-truth segmentation. We use 5000 contexts to train the autoregressive model. We use the Adam optimizer and train the model for 100 epochs with learning rate and batch size equal to 32.
For the evaluation the hyperparameters are: the number of random source points , the number of random contexts and the number of random Monte Carlo trials . We use masks of size , with 32 hidden channels and 1 layer.
D.2 Bound estimation
Now we can compute the final bound. The row sums of the global coupling matrix are defined as
where is the fitted decay, is the Euclidean distance between pixels and , and refers to the raster order of the autoregressive scan. Intuitively, aggregates the total residual dependence between and all in-bin pixels that follow it in the scan. From these row sums we can build the coefficients of Theorem 2.2:
Table 4: Computational time of the calibration methods.
| Binning | T-scal. | Beta-cal | Log.-cal | Iso-regr | Meta-cal | Sel.Scal | |
|---|---|---|---|---|---|---|---|
| Time (s) | 0.6 – 5 | 6 – 55 | 12 – 45 | 4 – 11 | 3 – 21 | 6 – 59 | 200 – 1200 |
where is the maximum variance across contexts estimated in D.1 and is the total number of bin- pixels across . In this estimation we assume for simplicity that all the images contributes the same. We approximate the bound by averaging over a random subset () of calibration images,
Moreover, for the marginal experiments we use an average of the coefficients:
Final bound Assembling all components, the marginal calibration bound (used in the experiments) at tolerance takes the form of Theorem 2.2:
The conditional bound is instead approximated as
E Implementation details and Computational Expenses
We perform each experiment using a GPU NVIDIA A100-SXM4-40GB. The average computing time of each method, for a calibration split, is given in Table 4.
F Additional Experiments
F.1 Additional Calibratio Experiments
In Figures 3-4 we report additional experiments for different choices of .
F.2 Binning Conditional Independece Assumption of Theorem 3.3
In this section we discuss the validity of the binning conditional independence assumption of Theorem 3.3, which states that , . In words, the assumption requires that, once the bin assignment of pixel is known, the bin assignments of the neighboring pixels carry no additional information about the label at . The intuition behind it is that the segmentation model is trained to aggregate information from surrounding pixels, so —and hence —has already absorbed the neighborhood context. This does not imply conditional independence, but it may make it hold approximately.
To assess the assumption empirically, we set up the following experiment. We train three autoregressive models and use them to approximate the matrix as in Section 4. Each model is trained with a different binning conditioning. The first uses no conditioning and learns ; the second is conditioned on , which is the setup used in our main experiments; and the third is conditioned on the full binning pattern, i.e.

Figure 3: Additional comparisons of validity curves , (in red) and empirical ones , across methods and datasets.

Figure 4: Additional comparisons of validity curves , (in red) and empirical ones , across methods and datasets.

Figure 5: Estimation of with different autoregressive models
. The results are reported in Fig. 5. The experiments neither reject nor confirm the assumption outright. As expected, however, they show that for some datasets, e.g Pet, conditioning on the full binning pattern has no—or only negligible—effect, whereas for others, e.g BUSI, the binning information contained in the neighborhood appears to influence the distribution of the label. A plausible explanation is that BUSI images often contain small-scale tumors, for which the surrounding pixel context is more informative, whereas the Pet dataset typically exhibits smooth, large-scale segmentation masks. Relaxing the conditioning dependence assumption, and deriving the corresponding generalization of the bound, is therefore a promising direction for future work.