  Many approaches to astronomical data reduction and analysis cannot tolerate
missing data: corrupted pixels must first have their values imputed. This paper
presents astrofix, a robust and flexible image imputation algorithm based on
Gaussian Process Regression (GPR). Through an optimization process, astrofix
chooses and applies a different interpolation kernel to each image, using a
training set extracted automatically from that image. It naturally handles
clusters of bad pixels and image edges and adapts to various instruments and
image types. For bright pixels, the mean absolute error of astrofix is several
times smaller than that of median replacement and interpolation by a Gaussian
kernel. We demonstrate good performance on both imaging and spectroscopic data,
including the SBIG 6303 0.4m telescope and the FLOYDS spectrograph of Las
Cumbres Observatory and the CHARIS integral-field spectrograph on the Subaru
Telescope.
