medpy.iterators.patchwise.CentredPatchIterator.assembleimage¶
-
static
CentredPatchIterator.
assembleimage
(patches, pmasks, gridids)[source]¶ Assemble an image from a number of patches, patch masks and their grid ids.
Parameters: patches : sequence
Sequence of patches.
pmasks : sequence
Sequence of associated patch masks.
gridids
Sequence of associated grid ids.
Returns: image : ndarray
The patches assembled back into an image of the original proportions.
Examples
Two-dimensional example: >>> import numpy >>> from medpy.iterators import CentredPatchIterator >>> arr = numpy.arange(0, 25).reshape((5,5)) >>> arr array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]])>>> patches, pmasks, gridids, _ = zip(*CentredPatchIterator(arr, 2)) >>> result = CentredPatchIterator.assembleimage(patches, pmasks, gridids) >>> numpy.all(arr == result) True
Five-dimensional example: >>> arr = numpy.random.randint(0, 10, range(5, 10)) >>> patches, pmasks, gridids, _ = zip(*CentredPatchIterator(arr, range(2, 7))) >>> result = CentredPatchIterator.assembleimage(patches, pmasks, gridids) >>> numpy.all(arr == result) True