This is most likely best done as reverse convolution or correlation. Numpy / scipy has code for both.
edit: including a small example.
Go here for the ipython laptop file: http://nbviewer.ipython.org/4020770/
I made a little gaussian and then used scipy.signal.correlate2d with the original image and a small subset.
You can see that the highest correlation values ββare centered around the subset of the image. note that for large kernels or images this code may take some time (because correlation is expensive)
source share