darsia.Patches#

class Patches(img, num_patches, **kwargs)[source]#

Bases: object

A 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:
basedarsia.Image

The full image.

num_patcheslist

Number of patches along each dimension.

patchesnumpy.ndarray

Array of sub-images of base.

Tile img into num_patches patches per dimension.

Parameters:
imgdarsia.Image

Image to be patched.

num_patcheslist of int

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).

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

base

Underlying base image.

num_patches

Number of patches in row, col, (depth, time).

num_active_spatial_axes

Active dimenion of patching.

relative_space_overlap

Relative overlap in each spatial dimension.

absolute_time_overlap

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.image

Assembled 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.Image

Assembled image as darsia image.

position(i, j)[source]#

Determine positioning of patch wrt. boundary or internal patches in both x- and y-direction.

Parameters:
iint

Patch coordinate in x-direction.

jint

Patch coordinate in y-direction.

Returns:
str

“left” or “right” if the patch is touching the left or right boundary of the image; otherwise “internal”.

str

“top” or “bottom” if the patch is touching the top or bottom boundary of the image; otherwise “internal”.

NOTE: The patch coordinates employ the Cartesian indexing, i.e., (x,y).
set_image(img, *args)[source]#

Update the image of a patch.

Parameters:
imgnp.ndarray

Image array.

*argstuple of int

Index of the patch.

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.