def _convolve(x, k): sx, ex, sy, ey = _kernel_margins(k.shape, margin_shift=True) return _do_convolve(x, k)[sx:ex, sy:ey]
def _convolve(x, k): sx, ex, sy, ey = _kernel_margins(k.shape, margin_shift=False) return _do_convolve(x, -1, k[::-1, ::-1])[sx:ex, sy:ey]