Suppose we have a matrix s of size 639 by 668, this matrix is fully composed by values of -1. We want to access and replace a section of 28X28 (e.g., Top-left corner), leaving a border of -1 around that specific submatrix. For that task we have initialized the following vector p (in MATLAB) and then access the section:
>> s = -ones(639, 668);
>> p = 2:29;
>> section = s(p, p); %Size 28X28
>> size(section)
ans =
28 28
Now we want to rewrite that code in Numpy/Python, assuming that the slicing is equivalent:
>>> import numpy as np
>>> s = -np.ones((639, 668))
>>> p = np.arange(1, 29)
>>> section = s[p, p]
>>> section.shape
(1, 28)
In this case is not possible to access the same section using the same vector (Note that the indices in numpy are based on 0). ¿It is possible to access that section in numpy using a similar process as in MATLAB?
Thanks in advance.