mindspore.dataset.vision.Perspective

View Source On Gitee
class mindspore.dataset.vision.Perspective(start_points, end_points, interpolation=Inter.BILINEAR)[source]

Apply perspective transformation on input image.

Parameters
  • start_points (Sequence[Sequence[int, int]]) – Sequence of the starting point coordinates, containing four two-element subsequences, corresponding to [top-left, top-right, bottom-right, bottom-left] of the quadrilateral in the original image.

  • end_points (Sequence[Sequence[int, int]]) – Sequence of the ending point coordinates, containing four two-element subsequences, corresponding to [top-left, top-right, bottom-right, bottom-left] of the quadrilateral in the target image.

  • interpolation (Inter, optional) – Image interpolation method defined by Inter . Default: Inter.BILINEAR.

Raises
  • TypeError – If start_points is not of type Sequence[Sequence[int, int]].

  • TypeError – If end_points is not of type Sequence[Sequence[int, int]].

  • TypeError – If interpolation is not of type Inter .

  • RuntimeError – If shape of the input image is not <H, W> or <H, W, C>.

Supported Platforms:

CPU

Examples

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>> from mindspore.dataset.transforms import Compose
>>> from mindspore.dataset.vision import Inter
>>>
>>> start_points = [[0, 63], [63, 63], [63, 0], [0, 0]]
>>> end_points = [[0, 32], [32, 32], [32, 0], [0, 0]]
>>> transforms_list = Compose([vision.Decode(),
...                            vision.Perspective(start_points, end_points, Inter.BILINEAR)])
>>> # apply the transform to dataset through map function
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns="image")
Tutorial Examples: