An N-dimentional iterator to slice arrays into uniform size windows.
Given the shape of an array and a window size, an ‘ndwindow_inside’ instance iterators over tuples of slices which slice an the array into uniform size wsize windows/sub-arrays. At each iteration, the index of the top left of the sub-array is incremented by one along the last dimension utill the resulting windows would extend past the array border. All sub-arrays are equal sized (wsize).
Parameters : | size : tuple of ints
wsize : tuple of ints
|
---|
See also
Examples
>>> a = np.arange(9).reshape(3,3)
>>> for s in ndwindow_inside(a.shape,(2,2)):
... print a[s]
[[0 1]
[3 4]]
[[1 2]
[4 5]]
[[3 4]
[6 7]]
[[4 5]
[7 8]]
Methods
__init__(shape, wsize) | Set up the object |
next(() -> the next value, ...) |