Class PadToSize

Inheritance Relationships

Base Type

Class Documentation

class PadToSize : public mindspore::dataset::TensorTransform

Pad the image to a fixed size.

Public Functions

explicit PadToSize(const std::vector<int32_t> &size, const std::vector<int32_t> &offset = {}, const std::vector<uint8_t> &fill_value = {0}, BorderType padding_mode = BorderType::kConstant)

Constructor.

Example
/* Define operations */
auto decode_op = vision::Decode();
auto pad_to_size_op = vision::PadToSize({256, 256}, {10, 20}, {255, 255, 255});

/* dataset is an instance of Dataset object */
dataset = dataset->Map({decode_op, pad_to_size_op},  // operations
                       {"image"});                   // input columns

参数
  • size[in] A two element vector representing the target size to pad, in order of [height, width].

  • offset[in] A two element vector representing the lengths to pad on the top and left, in order of [top, left]. Default: {}, means to pad symmetrically, keeping the original image in center.

  • fill_value[in] A vector representing the pixel intensity of the borders. Only valid if the padding_mode is BorderType.kConstant. If 1 value is provided, it is used for all RGB channels. If 3 values are provided, it is used to fill R, G, B channels respectively. Default: {0}.

  • padding_mode[in] The method of padding, which can be one of BorderType.kConstant, BorderType.kEdge, BorderType.kReflect or BorderType.kSymmetric. Default: BorderType.kConstant.

    • BorderType.kConstant, pads with a constant value.

    • BorderType.kEdge, pads with the last value at the edge of the image.

    • BorderType.kReflect, pads with reflection of the image omitting the last value on the edge.

    • BorderType.kSymmetric, pads with reflection of the image repeating the last value on the edge.

~PadToSize() = default

Destructor.