Class Pad

Inheritance Relationships

Base Type

Class Documentation

class Pad : public mindspore::dataset::TensorTransform

Pad the image according to padding parameters.

Public Functions

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

Constructor.

Example
/* Define operations */
auto decode_op = vision::Decode();
auto pad_op = vision::Pad({10, 10, 10, 10}, {255, 255, 255});

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

参数
  • padding[in] A vector representing the number of pixels to pad the image. If the vector has one value, it pads all sides of the image with that value. If the vector has two values, it pads left and right with the first and top and bottom with the second value. If the vector has four values, it pads left, top, right, and bottom with those values respectively.

  • 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.

  • padding_mode[in] The method of padding (default=BorderType.kConstant). Can be any of [BorderType.kConstant, BorderType.kEdge, BorderType.kReflect, BorderType.kSymmetric]

    • BorderType.kConstant, means it fills the border with constant values

    • BorderType.kEdge, means it pads with the last value on the edge

    • BorderType.kReflect, means it reflects the values on the edge omitting the last value of edge

    • BorderType.kSymmetric, means it reflects the values on the edge repeating the last value of edge

~Pad() = default

Destructor.