find_padding¶
tiatoolbox
.utils
.image
.find_padding
- find_padding(read_location, read_size, image_size)[source]¶
Find the correct padding to add when reading a region of an image.
- Parameters:
- Returns:
Tuple of padding to apply in the format expect by np.pad. i.e. ((before_x, after_x), (before_y, after_y)).
- Return type:
np.ndarray
Examples
>>> from tiatoolbox.utils.image import find_padding >>> location, size = (-2, -2), (10, 10) >>> # Find padding needed to make the output (10, 10) >>> # if the image is only (5 , 5) and read at >>> # location (-2, -2). >>> find_padding(location, size, image_size=(5, 5))