I am learning image convolution and in order to handle the edges, I want to repeat the first and last rows/columns of the original array (at the center) like this :
1 1 2 3 3
1 [1 2 3] 3
4 [4 5 6] 6
7 [7 8 9] 9
7 7 8 9 9
(The values in the corners correspond to the diagonal elements.)
I will iterate over each pixel of the original array and use the array above to extract its 3x3 neighbors. So here is my question: is it possible to generate the view corresponding to this array so that I don't need to store a new (n+2)x(m+2) array in memory?