Class RandomCrop

Inheritance Relationships

Base Type

Class Documentation

class RandomCrop : public mindspore::dataset::TensorTransform

Crop the input image at a random location.

Public Functions

explicit RandomCrop(std::vector<int32_t> size, std::vector<int32_t> padding = {0, 0, 0, 0}, bool pad_if_needed = false, std::vector<uint8_t> fill_value = {0, 0, 0}, BorderType padding_mode = BorderType::kConstant)

Constructor.

Parameters
  • size[in] A vector representing the output size of the cropped image. If the size is a single value, a squared crop of size (size, size) is returned. If the size has 2 values, it should be (height, width).

  • 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 top with the first and right and bottom with the second value. If the vector has four values, it pads left, top, right, and bottom with those values respectively.

  • pad_if_needed[in] A boolean indicating that whether to pad the image if either side is smaller than the given output size.

  • fill_value[in] A vector representing the pixel intensity of the borders 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).It can be any of [BorderType::kConstant, BorderType::kEdge, BorderType::kReflect, BorderType::kSymmetric].

    • BorderType::kConstant, Fill the border with constant values.

    • BorderType::kEdge, Fill the border with the last value on the edge.

    • BorderType::kReflect, Reflect the values on the edge omitting the last value of edge.

    • BorderType::kSymmetric, Reflect the values on the edge repeating the last value of edge.

~RandomCrop() = default

Destructor.