MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / compute_divisible_spatial_size

Function compute_divisible_spatial_size

monai/transforms/utils.py:1820–1837  ·  view source on GitHub ↗

Compute the target spatial size which should be divisible by `k`. Args: spatial_shape: original spatial shape. k: the target k for each spatial dimension. if `k` is negative or 0, the original size is preserved. if `k` is an int, the same `k` be appl

(spatial_shape: Sequence[int], k: Sequence[int] | int)

Source from the content-addressed store, hash-verified

1818
1819
1820def compute_divisible_spatial_size(spatial_shape: Sequence[int], k: Sequence[int] | int):
1821 """
1822 Compute the target spatial size which should be divisible by `k`.
1823
1824 Args:
1825 spatial_shape: original spatial shape.
1826 k: the target k for each spatial dimension.
1827 if `k` is negative or 0, the original size is preserved.
1828 if `k` is an int, the same `k` be applied to all the input spatial dimensions.
1829
1830 """
1831 k = fall_back_tuple(k, (1,) * len(spatial_shape))
1832 new_size = []
1833 for k_d, dim in zip(k, spatial_shape):
1834 new_dim = int(np.ceil(dim / k_d) * k_d) if k_d > 0 else dim
1835 new_size.append(new_dim)
1836
1837 return tuple(new_size)
1838
1839
1840def equalize_hist(

Callers 3

pad_imagesFunction · 0.90
compute_pad_widthMethod · 0.90
compute_bounding_boxMethod · 0.90

Calls 2

fall_back_tupleFunction · 0.90
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…