Image subtraction is a method by which one image is matched against another
by using a convolution kernel, so that they can be differenced to detect a
nd measure variable objects. It has been demonstrated that constant optimal
-kernel solutions can be derived over small sub-areas of dense stellar fiel
ds. Here we generalize the: theory to the case, of space-varying kernels. I
n particular, it is shown that the CPU cost required for this new extension
of the method is almost the same as for fitting a constant kernel solution
. It is also shown that constant flux scaling between the images (constant
kernel integral) can be imposed in a simple way. The method is demonstrated
with a series of Monte-Carlo images. Differential PSF variations and diffe
rential rotation between the images are simulated. It is shown that the new
method is able to achieve optimal results even in these difficult cases, t
hereby automatically correcting for these common instrumental problems. It
is also demonstrated that the method does not suffer due to problems associ
ated with undersampling of the images. Finally, the method is applied to im
ages taken by the OGLE II collaboration. It is proved that, in comparison t
o the constant-kernel method, much larger sub-areas of the images can be us
ed for the fit, while still maintaining the same accuracy in the subtracted
image. This result is especially important in case of variables located in
low density fields, like the Huchra lens. Many other useful applications o
f the method are possible for major astrophysical problems; Supernova searc
hes anti Cepheids surveys in other galaxies, to mention but two. Many other
applications will certainly show-up, since variability searches are a majo
r issue in astronomy.