Context. Gaia is Europe's space astrometry mission, aiming to make a three-dimensional map of 1000 million stars in our Milky Way to unravel its kinematical, dynamical, and chemical structure and evolution.Aims. We present a study of Gaia's detection capability of objects, in particular non-saturated stars, double stars, unresolved external galaxies, and asteroids. Gaia's on-board detection software autonomously discriminates stars from spurious objects like cosmic rays and solar protons. For this, parametrised criteria of the shape of the point spread function are used, which need to be calibrated and tuned. This study aims to provide an optimum set of parameters for these filters. Methods. We developed a validated emulation of the on-board detection software, which has 20 free, so-called rejection parameters which govern the boundaries between stars on the one hand and sharp (high-frequency) or extended (low-frequency) events on the other hand. We evaluate the detection and rejection performance of the algorithm using catalogues of simulated single stars, resolved and unresolved double stars, cosmic rays, solar protons, unresolved external galaxies, and asteroids. Results. We optimised the rejection parameters, improving -with respect to the functional baseline -the detection performance of single stars and of unresolved and resolved double stars, while, at the same time, improving the rejection performance of cosmic rays and of solar protons. The optimised rejection parameters also remove the artefact of the functional-baseline parameters that the reduction of the detection probability of stars as a function of magnitude already sets in before the nominal faint-end threshold at G = 20 mag. We find, as a result of the rectangular pixel size, that the minimum separation to resolve a close, equal-brightness double star is 0.23 arcsec in the along-scan and 0.70 arcsec in the across-scan direction, independent of the brightness of the primary. To resolve double stars with ∆G > 0 mag, larger separations are required. We find that, whereas the optimised rejection parameters have no significant impact on the detectability of pure de Vaucouleurs profiles, they do significantly improve the detection of pure exponential-disk profiles, and hence also the detection of unresolved external galaxies with intermediate profiles. We also find that the optimised rejection parameters provide detection gains for asteroids fainter than 20 mag and for fast-moving near-Earth objects fainter than 18 mag, although this gain comes at the expense of a modest detection-probability loss for bright, fast-moving near-Earth objects. The major side effect of the optimised parameters is that spurious ghosts in the wings of bright stars essentially pass unfiltered.