mindspore.dataset.vision.Perspective
- 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) –
Method of interpolation. It can be
Inter.BILINEAR
,Inter.LINEAR
,Inter.NEAREST
,Inter.AREA
,Inter.PILCUBIC
,Inter.CUBIC
orInter.BICUBIC
. Default:Inter.BILINEAR
.Inter.BILINEA
, bilinear interpolation.Inter.LINEAR
, linear interpolation, the same as Inter.BILINEAR.Inter.NEAREST
, nearest-neighbor interpolation.Inter.BICUBIC
, bicubic interpolation.Inter.CUBIC
, cubic interpolation, the same as Inter.BICUBIC.Inter.PILCUBIC
, cubic interpolation based on the implementation of Pillow, only numpy.ndarray input is supported.Inter.AREA
:, pixel area interpolation, only numpy.ndarray input is supported.
- 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
mindspore.dataset.vision.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: