## 3 Analysis of Contrast Extraction Algorithms
### Calibration with the Zero-Contrast Baseline
This is a result of the mask fabrication tolerance, which was also confirmed by the SEM image as shown in Figure 3d. By varying the aperture size and assigning a Gaussian distributed position error for individual apertures, we were able to replicate the observation. Shown in Figure 3e in '+' or 'x' marker are histograms of simulated data considering aperture astigmatism. The histogram, however, is sensitive to both the averaged aperture size and their position errors. Small deviations from the identified values will result in very different shapes of the photon peaks in the histogram, which are plotted in light/dark green for comparison. We further estimated the systematic errors of contrast extraction when the detector mask is applied by simulating the detector signal using the identified realistic parameters for the detector mask. For the zero-contrast reference speckle patterns, the extracted photon probabilities from rounded pixel values yielded a contrast \(-0.007\pm 0.002\). Here, the error bar was estimated from the photon statistics in the simulation. It suggests that the mask led to a \(\sim\)0.7% contrast underestimation. Shown in Figure 3c are the contrasts extracted from the unfocused scattering data set when the mask was applied, and it gave a contrast of \(-0.006\pm 0.005\). Considering the systematic error from the imperfect detector mask, we arrive at a contrast level of 0.1%. This demonstrates that the contrast level extracted under the unfocused condition \(\beta_{b}\) can be used as an effective calibration reference. It is, however, worth noting here that this procedure will introduce additional errors due to error propagation from both \(\beta_{e}\) and \(\beta_{b}\). Figure 3: Detector mask to confirm unfocused beam as the zero-contrast calibration point. (**a**) Schematic of the detector mask with circular apertures that have a nominal diameter of 35 \(\upmu\)m aligned to every other pixel of the epix100 detector. (**b**) Regions within a single pixel that have different single-photon contribution fractions assuming a Gaussian charge cloud with a size of 0.385 pixel (FWHM), which reproduces the pixel histogram of the ePix100 detectors. The black area denotes the region where a photon will contribute 98% of its generated charges to the readout of this pixel. The gray area denotes the region for more than 60% of the charges to be collected by this pixel. (**c**) Extracted contrast from the scattering of unfocused beam with the mask aligned with the detector. (**d**) Scanning electron microscope measurement of the mask (scale bar: 100 \(\upmu\)m). (**e**) Simulated and measured pixel histograms of the detector with different parameters of the mask. Here, \(\sigma\) is the standard deviation of the Gaussian distributed position error of individual apertures. The nanopowder sample was considered static during the course of the measurement. Therefore, one can retrieve the absolute contrast levels for benchmarking the calibration protocol by evaluating the sequential cross-correlations. We performed intensity cross-correlation of adjacent frames using the same ROI as the visibility analysis. To improve the signal to noise ratio, only frame pairs both having count rates above 0.2 photons per pixel [23] were used. For calculating the correlation, we set the pixel readout threshold at half a nominal photon readout, i.e., 85 ADU, in order to mitigate the bias arising from the pixel readout noise. Considering the intensity fluctuations and shot noise, the correlation was extracted by performing the weighted average of the cross-correlations [24]. The weighting factors were proportional to the intensity multiplication of the pulse pair, which were measured independently using the beamline \(I_{0}\) right upstream of the sample. Their error bars were estimated using the weighted variance. After normalizing the correlation from each condition to that of the unfocused beam, the final contrast values were compared against the calibrated GG result as shown in Figure 4, showing good general agreement.