mindspore.dataset.vision.c_transforms.SlicePatches

class mindspore.dataset.vision.c_transforms.SlicePatches(num_height=1, num_width=1, slice_mode=SliceMode.PAD, fill_value=0)[source]

Slice Tensor to multiple patches in horizontal and vertical directions.

The usage scenario is suitable to large height and width Tensor. The Tensor will keep the same if set both num_height and num_width to 1. And the number of output tensors is equal to num_height*num_width.

Parameters
  • num_height (int, optional) – The number of patches in vertical direction (default=1).

  • num_width (int, optional) – The number of patches in horizontal direction (default=1).

  • slice_mode (Inter mode, optional) – A mode represents pad or drop (default=SliceMode.PAD). It can be any of [SliceMode.PAD, SliceMode.DROP].

  • fill_value (int, optional) – The border width in number of pixels in right and bottom direction if slice_mode is set to be SliceMode.PAD (default=0).

Examples

>>> # default padding mode
>>> decode_op = c_vision.Decode()
>>> num_h, num_w = (1, 4)
>>> slice_patches_op = c_vision.SlicePatches(num_h, num_w)
>>> transforms_list = [decode_op, slice_patches_op]
>>> cols = ['img' + str(x) for x in range(num_h*num_w)]
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns=["image"],
...                                                 output_columns=cols, column_order=cols)