darsia.random_patches#

random_patches(mask, width, num_patches)[source]#

Utility to extract random patches from a mask.

Parameters:
masknp.ndarray

Binary mask to extract patches from.

widthint

Width of the patches.

num_patchesint

Number of patches to extract.

Returns:
list of tuples

Patches as slices.

None

If the mask is too small to extract patches.

NOTE: The function utilizes randomness. For reproducibility, the seed is fixed.