I’ll just explain the logic, because I don’t have time to write the code myself. The short answer is that you have to go through each pixel of the map image, and if any pixels in the vicinity (that is, at some distance) are considered "ground", then you register the current pixel as part of the fill area.
For a long answer, here are 9 steps to achieve your goal.
1. Determine the size of the gasket. Say 6 pixels.
2. Create a map image in monochrome (black - "water", white - "earth"). Leave a margin of at least 6 pixels along the edge. This is the input image: (it does not scale)

3. Create an image of a circle with a diameter of 11 pixels (11 = 6 * 2-1). Again, black is empty / transparent, white is solid. This is the image of the hit area:

4. Create a third picture that is all black (for starters). Make it the same size as the input image. It will be used as the output image.
5. Iterate each pixel of the input image.
6. The image of the hit area is superimposed on this pixel (just do it practically by calculation) so that the center of the hit area (white circle) is above the current pixel of the input image.
7. Now iterate over each pixel in the hit area image.
8. If any white pixel of the image of the hit area intersects the white pixel of the input image, then draw a white pixel (where the center of the circle) on the output image.
9. Go to step 5.
Admittedly, starting from step 6 is not so simple, but it is quite easy to implement. Hope you understand the logic. If my explanation is too confusing (sorry), I could spend some time writing a complete solution (in Javascript, C # or Haskell).