Zero-pad a two-dimensional grayscale image on every side, then extract a centered crop with the requested dimensions.