Context. Deep photometric surveys of substellar objects in young clusters and high-redshift quasars are affected by contaminant sources at different heliocentric distances. If not correctly taken into account, the contamination may have a strong effect on the Initial Mass Function determination and on the identification of quasars. Aims. We calculate in detail the back-and foreground contamination by field dwarfs of very late spectral types (intermediate and late M, L, and T) in deep surveys and provide the data and tools for the computation. Methods. We adopt the latest models and data from the literature, which include the following: (i) a model of the Galactic thin disc by an exponential law; (ii) the length and height scales of late-type dwarfs; and (iii) the local spatial densities, absolute magnitudes, and colours of dwarfs for each spectral type. Results. We derive a simplified expression for the spatial density in the thin disc that depends on the heliocentric distance and the galactic coordinates (l, b) and integrate this into the truncated cone studied in the survey. As a practical application, we compute the numbers of L-and T-type field dwarfs in very deep (I = 21−29 mag) surveys in the direction of the young σ Orionis cluster. The increasing number of contaminants at the faintest magnitudes could inhibit the study of the opacity mass limit at M < ∼ 0.003 M in the cluster.