medpy.iterators.patchwise.SlidingWindowIterator#
- class medpy.iterators.patchwise.SlidingWindowIterator(array, psize, cval=0)[source]#
Moves a sliding window over the array, where the first patch is places centered on the top-left voxel and outside-of-image values filled with cval. The returned patches are views if the array.
All yielded patches will be of size
psize. Areas outside of the array are filled withcval. Besides the patch, a patch mask is returned, that denoted the outside values.Central element for even patches:
- [[0, 0],
[0, X]]
- Parameters:
- arrayarray_like
A n-dimensional array.
- psizeint or sequence of ints
The patch size. If a single integer interpreted as hyper-cube.
- cvalnumber
Value to fill undefined positions.
Methods
__init__(array, psize[, cval])applyslicer(array, slicer[, cval])Apply a slicer returned by the iterator to a new array of the same dimensionality as the one used to initialize the iterator.
next()Yields the next patch.