You could probably save a lot of addition operations by refactoring these loops, e.g. if you let `i` be the index of the first cell in the window, i.e. `padded[i: i + 2 * offset, ...]`