  Stacks of digital astronomical images are combined in order to increase image
depth. The variable seeing conditions, sky background and transparency of
ground-based observations make the coaddition process non-trivial. We present
image coaddition methods optimized for source detection and flux measurement,
that maximize the signal-to-noise ratio (S/N). We show that for these purposes
the best way to combine images is to apply a matched filter to each image using
its own point spread function (PSF) and only then to sum the images with the
appropriate weights. Methods that either match filter after coaddition, or
perform PSF homogenization prior to coaddition will result in loss of
sensitivity. We argue that our method provides an increase of between a few and
25 percent in the survey speed of deep ground-based imaging surveys compared
with weighted coaddition techniques. We demonstrate this claim using simulated
data as well as data from the Palomar Transient Factory data release 2. We
present a variant of this coaddition method which is optimal for PSF or
aperture photometry. We also provide an analytic formula for calculating the
S/N for PSF photometry on single or multiple observations. In the next paper in
this series we present a method for image coaddition in the limit of
background-dominated noise which is optimal for any statistical test or
measurement on the constant-in-time image (e.g., source detection, shape or
flux measurement or star-galaxy separation), making the original data
redundant. We provide an implementation of this algorithm in MATLAB.
