Count2Density: Mapping Counts to Density
- Count2Density is a framework that transforms point annotations or global counts into spatially resolved density maps using Gaussian kernels and weakly supervised strategies.
- It bridges diverse applications by converting count-only cues into meaningful density representations in computer vision, microscopy, and astrophysical analyses.
- Key challenges include spatial granularity, indirect supervision, and model mismatches, driving research toward adaptive kernels and stronger density priors.
Searching arXiv for the key papers on Count2Density and closely related density/counting frameworks. arXiv search queries:
- id:(Litrico et al., 3 Sep 2025)
- id:(Guo et al., 21 Dec 2025)
- id:(Dai et al., 2019)
- id:(Jiang et al., 2018)
- id:(Chen et al., 2019) Count2Density denotes a family of formulations in which aggregate counts, count-in-cell observables, or column-density measurements are transformed into spatial density representations, density-aware latent variables, or characteristic local densities. In computer vision, the term appears both in the classical density-map paradigm—where point annotations are convolved with Gaussian kernels so that the density integral equals the object count—and in newer weakly supervised settings that attempt to recover meaningful density maps from count-only supervision (Dai et al., 2019, Litrico et al., 3 Sep 2025). In parallel, related count-to-density inversions appear in microscopy, where density maps are decoded into local object counts and locations, and in astrophysics and cosmology, where column densities or counts in cells are mapped to number densities or projected density PDFs (Li et al., 2022, Gaches et al., 2024, Pinon et al., 24 Jan 2025).
1. Scope of the Count2Density formulation
In image-based counting, the canonical Count2Density mapping begins from point annotations and defines a density target as a sum of Gaussian kernels,
with the normalization chosen so that integrating or summing the map yields the count (Dai et al., 2019). Variants differ in whether is geometry-adaptive, fixed, or dataset-specific, but the operational principle is stable: density is a spatially resolved surrogate for count (Jiang et al., 2018, Gao et al., 2020).
A second usage of Count2Density emerges when only image-level counts are available. In that setting, the task is no longer to regress a known density target, but to induce internal or explicit density structure from a scalar supervision signal. Count2Density formalizes this as recovering “meaningful density maps containing quantitative spatial information using only count-level annotations” via pseudo-density generation, historical averaging, and contrastive spatial regularization (Litrico et al., 3 Sep 2025). TCFormer expresses the same idea at the feature level: image-level counts supervise token-level density scores and a density-aware aggregation module, so that counts induce “internal representations that behave like density maps (or density-related weights)” without location labels (Guo et al., 21 Dec 2025).
A third usage appears outside vision datasets with point supervision. In molecular-cloud analysis, observed column density is decomposed into turbulent and gravitational components and mapped to characteristic number densities and , plus an effective attenuating column (Gaches et al., 2024). In cosmology, counts in top-hat cells are related probabilistically to smoothed density contrast through , and density-split clustering is then expressed in terms of one- and two-point PDFs of that density field (Gruen et al., 2017, Pinon et al., 24 Jan 2025). This suggests that Count2Density is best understood as a general inversion principle linking discrete or integrated observables to a structured density description.
| Regime | Input supervision / observable | Density object |
|---|---|---|
| Classical crowd or object counting | Point annotations | Pixel-wise density map whose sum equals count |
| Weakly supervised crowd counting | Image-level global count 0 | Pseudo-density map, token-level density scores, or density-related weights |
| Physical/statistical inversion | Column density or counts in cells | Characteristic number density or smoothed density PDF |
2. Classical density-map counting with explicit spatial supervision
The fully supervised Count2Density literature treats density estimation as the core representation, with count obtained by integration. DSNet exemplifies this paradigm through a VGG-16 front-end, three Dense Dilated Convolution Blocks, dense residual connections, and a multi-scale density level consistency loss. Its density targets use geometry-adaptive kernels for congested datasets and fixed kernels for sparse datasets, and the resulting count is computed as 1 (Dai et al., 2019). The architectural emphasis is on continuous scale coverage: dilation rates 2 are chosen to avoid gridding artifacts while preserving local continuity of the predicted density map (Dai et al., 2019).
Mask-aware counting refines the same density-map formulation by separating foreground/background segmentation from density regression. The binary mask 3 is derived from the density itself, and a dedicated mask branch is trained with pixel-wise classification loss while the density branch uses the mask posterior as an additional conditioning signal (Jiang et al., 2018). The best-performing design does not simply multiply density by a hard mask; instead, it transforms the predicted posterior into multi-channel mask features and fuses them with backbone features before density regression, so that gradients from density loss also update the mask predictor (Jiang et al., 2018). This addresses the asymmetry between sparse non-zero density support and dominant background pixels.
Remote-sensing counting adopts the same density-map logic but adapts it to extreme scale variation, orientation arbitrariness, and clutter. ASPDNet constructs density maps from object-center impulses convolved with a fixed Gaussian kernel with 4, then regresses them with a VGG16 front-end augmented by CBAM, a Scale Pyramid Module with dilated convolutions, and a Deformable Convolution Module (Gao et al., 2020). The count remains 5, but the architecture is specialized for remote-sensing morphology rather than pedestrian crowds (Gao et al., 2020).
A related supervised line focuses on extracting more information from point annotations than Gaussian-density generation alone. “Focus for Free in Density-Based Counting” repurposes point annotations to create object-aware occlusion simulation, foreground masks, an auxiliary foreground-only teacher, and segmentation/global-density focus branches (Shi et al., 2023). The underlying density target remains standard, but the learning signal becomes richer: the main regressor is distilled toward a density map predicted from blacked-out-background inputs, reducing background interference while preserving the Count2Density integral relation (Shi et al., 2023).
3. Count-only supervision and the recovery of spatial density
The most explicit Count2Density formulation under weak supervision is the 2025 pipeline that learns density maps from image-level counts alone (Litrico et al., 3 Sep 2025). A feature extractor 6 and decoder 7 predict 8, with global count recovered by summation,
9
Since no ground-truth density map is available, the method maintains a Historical Map Bank 0, initialized with BASNet saliency and updated by an exponential moving average,
1
with 2 (Litrico et al., 3 Sep 2025). Each historical map is normalized into a spatial prior, from which exactly 3 pseudo-locations are sampled using a hypergeometric-like scheme without replacement; these sampled points are then converted into a pseudo-density map 4, yielding a map loss plus a contrastive spatial regularizer that encourages intra-crowd feature similarity and crowd/background separation (Litrico et al., 3 Sep 2025). The paper reports that the Historical Map Bank is the dominant contributor in ablation, and that hypergeometric sampling substantially outperforms a naïve top-5 strategy (Litrico et al., 3 Sep 2025).
TCFormer solves a closely related problem with a different mechanism. It uses TinyViT as a 4-stage hierarchical backbone and predicts only from image-level global counts 6, with no point annotations, no density maps, and no bounding boxes (Guo et al., 21 Dec 2025). The final stage produces 7 tokens, and the Learnable Density-Weighted Averaging module assigns each token a scalar density score,
8
before constructing a density-weighted global descriptor,
9
There is no explicit loss on 0 or 1; the token weights are learned only through count regression, so minimizing count error forces high-density regions to receive larger weights and background regions to be down-weighted (Guo et al., 21 Dec 2025). TCFormer further introduces a density-level classification loss obtained by uniformly quantizing the global count range into 2 grades, thereby adding a discrete density supervision signal derived entirely from counts (Guo et al., 21 Dec 2025). This suggests two distinct Count2Density strategies under weak supervision: explicit pseudo-density reconstruction (Litrico et al., 3 Sep 2025) and implicit density-aware feature aggregation (Guo et al., 21 Dec 2025).
A common misconception is that count-only supervision can only support scalar regression. The weakly supervised literature here contradicts that view in two ways. First, Count2Density reports meaningful density maps supporting subregion counting and localization despite using only image-level counts during training (Litrico et al., 3 Sep 2025). Second, TCFormer shows that even when explicit density maps are absent, token-level density scores and weights can behave as coarse density surrogates under global-count supervision (Guo et al., 21 Dec 2025). At the same time, both papers also delimit the achievable resolution: Count2Density relies on iterative pseudo-label refinement and substantial memory for the Historical Map Bank, while TCFormer operates on a 3 final token grid at 4 resolution and therefore learns only coarse spatial density structure (Litrico et al., 3 Sep 2025, Guo et al., 21 Dec 2025).
4. Alternative count–density couplings beyond direct density regression
Several systems depart from the simple rule “predict density, integrate to count” while retaining density as an auxiliary or intermediate structure. DeepCount is a density-aware global count regressor: during training, a single-column backbone predicts a scalar count together with five auxiliary density maps at progressively coarser resolutions, obtained from multilevel pixelation of the original density map by repeated 5 sum pooling (Chen et al., 2019). The key argument is that pixelation increases SNR exponentially with depth, so coarse density targets provide more robust supervision than a single high-resolution map. The backbone is trained by multilayer gradient fusion from all branches, but at test time the density branches can be detached, yielding a faster count-only model (Chen et al., 2019). Count is therefore not computed as 6, yet the count regressor remains density-aware by construction.
DENet combines counting-by-detection and counting-by-density-estimation. A Mask R-CNN detector counts clearly visible people, producing 7, while an encoder–decoder estimation network predicts a density map on the remaining masked image, producing 8. The final count is
9
and training includes a counting loss that explicitly enforces global consistency between detection count, density integral, and ground-truth count (Liu et al., 2019). This architecture is a concrete Count2Density decomposition across visibility regimes: sparse, segmentable individuals are counted discretely; dense ambiguous regions are represented as continuous density (Liu et al., 2019).
A different variant appears in high-density object localization from aerial imagery. The network of (Arruda et al., 2021) predicts per-pixel confidence maps 0 across multiple refinement stages, with each stage supervised by Gaussian kernels of different 1. Although the representation is density-like, inference counts peaks rather than integrating the map: 2 with 3 and minimum separation 4 pixel (Arruda et al., 2021). This suggests a useful distinction: not every Count2Density representation is a normalized density whose sum equals the count; some are center-likelihood maps whose count is obtained by peak enumeration (Arruda et al., 2021).
Microscopy work pushes this distinction further. “Improved Counting and Localization from Density Maps for Object Detection in 2D and 3D Microscopy Imaging” argues that plain integration of the density map can preserve global count while failing at localization when peaks merge (Li et al., 2022). The proposed Density Map Analysis interprets the predicted density as a mixture of Gaussian components, computes truncated mass inside each thresholded connected component, and estimates a local object count by dividing that truncated mass by the fixed mass 5 of a Gaussian above threshold 6. Components with counts near 1 are rounded, while merged components use the estimated integer count as a prior for Gaussian Mixture Model fitting on Monte Carlo samples drawn from the normalized density within the blob (Li et al., 2022). Here the Count2Density relation becomes local and statistical rather than purely integral.
5. Physical and statistical Count2Density outside image supervision
The same logical structure appears in astrophysical inversion. In molecular-cloud analysis, the observable is not an object count but a column density map 7, and the goal is to infer local representative number densities along the line of sight. The proposed probabilistic model assumes
8
where 9 is a turbulent column drawn from a truncated lognormal prior and 0 is a gravitational component associated with a Jeans-scale dense structure (Gaches et al., 2024). Given a sampled 1, the residual column 2 is used to solve for a dense number density 3, while the remaining path length yields a diffuse density 4. The method thereby maps a 2D column-density observable into pixel-wise distributions over 5, plus an effective attenuating column 6 for astrochemical modeling (Gaches et al., 2024). This is a physical Count2Density inversion rather than a supervised learning problem.
In cosmology, the inversion is framed in terms of counts in cells and density-split clustering. For spherical top-hat smoothing, counts in a cell satisfy
7
and the observable counts PDF is modeled as
8
with 9 typically Poisson or generalized Poisson and 0 modeled by Gaussian, shifted lognormal, or Large Deviation Theory (Gruen et al., 2017, Pinon et al., 24 Jan 2025). Density-split correlation functions are then expressed through the two-point PDF of 1, and the environmental dependence is summarized by a density bias function 2 (Pinon et al., 24 Jan 2025). Earlier density-split work in DES Y1 and SDSS already used galaxy counts in apertures to split lines of sight by density and calibrated the count-to-density relation with weak lensing, thereby constraining cosmology, galaxy bias, stochasticity, and skewness of the matter PDF (Gruen et al., 2017). “Cylinders out of a top hat” similarly constructs projected count-in-cylinder densities and derives their one-point PDF and cylinder bias from large deviation statistics (Uhlemann et al., 2017).
A misconception in this statistical literature is that simple Gaussian or lognormal assumptions are always sufficient once one has a smoothed count field. The supplied papers argue otherwise: Gaussian approximations fail for density-split clustering at relevant mildly nonlinear scales, shifted lognormal improves but remains systematically less accurate, and LDT provides the best agreement in the large-separation regime (Pinon et al., 24 Jan 2025). Likewise, line-of-sight number-density inference depends materially on assumptions about cloud depth 3, temperature 4, and the turbulence model, so Count2Density in physical systems is inseparable from the prior imposed on the latent density field (Gaches et al., 2024).
6. Limitations, misconceptions, and open directions
Across these literatures, the first recurrent limitation is spatial granularity. TCFormer’s final representation comprises 5 tokens at 6 input, which is sufficient for global counting but not for fine-grained density detail (Guo et al., 21 Dec 2025). DeepCount intentionally moves toward coarser density maps because pixelation improves SNR, but this also means the auxiliary density structure is lower resolution than a classical full-resolution map (Chen et al., 2019). In cosmological LDT-based modeling, accuracy depends on large separations 7, so small-scale density-split correlations remain outside the formal regime of control (Pinon et al., 24 Jan 2025).
The second limitation is the indirectness of supervision. Count2Density’s Historical Map Bank can recover useful pseudo-density maps from count labels alone, but it stores a full map per training image and increases training cost and memory linearly with dataset size and resolution (Litrico et al., 3 Sep 2025). TCFormer’s LDWA weights are never directly supervised, and there is no explicit compositional constraint tying a function of 8 to the count (Guo et al., 21 Dec 2025). DeepCount’s backbone becomes density-aware through auxiliary branches, yet those branches are discarded at test time, so the learned density structure remains implicit rather than directly inspectable unless a branch is retained (Chen et al., 2019).
The third limitation is model mismatch. In microscopy, density-based counting assumes object contributions are approximately Gaussian with shared covariance; when this breaks, truncated-mass counting and GMM-based localization become only approximate (Li et al., 2022). In remote sensing, ASPDNet uses a fixed Gaussian kernel with 9 for all objects, even though object scales vary strongly across categories and scenes (Gao et al., 2020). In molecular clouds, inferred 0 and 1 depend on choices for 2, 3, and the lognormal turbulent prior (Gaches et al., 2024). In density-split clustering, Count2Density mappings inherit the limitations of the bias model and shot-noise model used for 4 (Gruen et al., 2017, Pinon et al., 24 Jan 2025).
Taken together, the literature suggests two broad research directions. One is to tighten the coupling between count constraints and density structure: examples already proposed include region-level weak labels, pseudo-density consistency losses, and image-conditioned density-level heads for weakly supervised crowd counting (Guo et al., 21 Dec 2025). The other is to make the density prior more faithful to the domain: adaptive kernels, physically richer priors, multi-scale tokens, and improved stochasticity models all serve the same purpose of making the inferred density field more than a counting surrogate. In that sense, Count2Density is not a single architecture but a unifying problem class: how to turn coarse or indirect observables into density representations that remain quantitatively meaningful for counting, localization, or physical inference (Litrico et al., 3 Sep 2025, Gaches et al., 2024, Pinon et al., 24 Jan 2025).