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

Method _get_params

monai/transforms/spatial/array.py:3240–3258  ·  view source on GitHub ↗

Calculate the size and step required for splitting the image Args: The size of the input image

(self, image_size: Sequence[int] | np.ndarray, size: Sequence[int] | np.ndarray | None = None)

Source from the content-addressed store, hash-verified

3238 return patches
3239
3240 def _get_params(self, image_size: Sequence[int] | np.ndarray, size: Sequence[int] | np.ndarray | None = None):
3241 """
3242 Calculate the size and step required for splitting the image
3243 Args:
3244 The size of the input image
3245 """
3246 if size is None:
3247 # infer each sub-image size from the image size and the grid
3248 size = tuple(image_size[i] // self.grid[i] for i in range(len(self.grid)))
3249
3250 if any(size[i] > image_size[i] for i in range(len(self.grid))):
3251 raise ValueError(f"The image size ({image_size})is smaller than the requested split size ({size})")
3252
3253 steps = tuple(
3254 (image_size[i] - size[i]) // (self.grid[i] - 1) if self.grid[i] > 1 else image_size[i]
3255 for i in range(len(self.grid))
3256 )
3257
3258 return size, steps
3259
3260
3261class GridPatch(Transform, MultiSampleTrait):

Callers 1

__call__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected