from the source position, and summing all photons at shorter distance [^7]. A reference profile for the instrument PSF was calculated in the same way. The two profiles were then compared with a Kolmogorov-Smirnov (KS) test. Under the null hypothesis that they are drawn from the same distribution, this procedure gives us the probability that the source image is not consistent with being unresolved in the core region. An example is shown in Figure \[kstest\]. Based on this procedure, we can classify the source as unresolved or extended by setting a threshold on the null-hypothesis probability of the KS test. This threshold must be chosen [*a posteriori*]{} after extensive simulations to keep both the contamination and the completeness of the sample under control. This is shown for [*Swift*]{}-XRT in §\[simu\].

The KS null-hypothesis probability also depends on the net detected photons and the background level. As we show in Section 3, one simple but effective way is to set the threshold that divides the unresolved from the extended source in the probability-S/N plane. The optimal threshold is determined through extensive simulations by computing the completeness (fraction of recovered extended sources) and the contamination (number of sources spuriously classified as extended) 