darsia.Patches#
- class Patches(img, num_patches, **kwargs)[source]#
Bases:
objectA full image tiled into a regular array of patches.
Patches are addressed with standard matrix indexing: the upper-left (front) patch has coordinate
(0, 0)((0, 0, 0)in 3d).- Attributes:
- base
darsia.Image The full image.
- num_patches
list Number of patches along each dimension.
- patches
numpy.ndarray Array of sub-images of
base.
- base
Tile
imgintonum_patchespatches per dimension.- Parameters:
- img
darsia.Image Image to be patched.
- num_patches
listofint Number of patches per dimension, in the same axis order as
img(including the time axis). If its length equals the spatial dimension, the whole time slab is kept as one.- **kwargs
"rel_overlap"(int) – spatial overlap of each patch relative to the patch size, per direction (default 0)."abs_time_overlap"(int) – absolute overlap of each patch along the time axis (default 0).
- img
Methods
assemble([update_img])Reassembles without taking into account the overlap.
blend_and_assemble([update_img])Reassembles taking into account the overlap as well.
position(i, j)Determine positioning of patch wrt.
set_image(img, *args)Update the image of a patch.
Attributes
Underlying base image.
Number of patches in row, col, (depth, time).
Active dimenion of patching.
Relative overlap in each spatial dimension.
Absolute overlap in temporal dimension.
- assemble(update_img=False)[source]#
Reassembles without taking into account the overlap.
- Parameters:
- update_imgbool
Flag controlling whether the base image will be updated with the assembled image; default set to False.
- Returns:
darsia.imageAssembled image as darsia image.
- blend_and_assemble(update_img=False)[source]#
Reassembles taking into account the overlap as well. On the overlap, a convex combination is used for smooth blending.
- Parameters:
- update_imgbool
Flag controlling whether the base image will be updated with the assembled image; default set to False.
- Returns:
darsia.ImageAssembled image as darsia image.
- position(i, j)[source]#
Determine positioning of patch wrt. boundary or internal patches in both x- and y-direction.
- Parameters:
- Returns:
- set_image(img, *args)[source]#
Update the image of a patch.
- Parameters:
- img
np.ndarray Image array.
- *args
tupleofint Index of the patch.
- img
- absolute_time_overlap#
Absolute overlap in temporal dimension.
- base#
Underlying base image.
- num_active_spatial_axes#
Active dimenion of patching. Remaining dimensions will not be patched.
- num_patches#
Number of patches in row, col, (depth, time).
- relative_space_overlap#
Relative overlap in each spatial dimension.