Class RandomCrop
Defined in File vision.h
Inheritance Relationships
Base Type
public mindspore::dataset::TensorTransform
(Class TensorTransform)
Class Documentation
-
class RandomCrop : public mindspore::dataset::TensorTransform
Crop the input image at a random location.
Public Functions
-
explicit RandomCrop(const std::vector<int32_t> &size, const std::vector<int32_t> &padding = {0, 0, 0, 0}, bool pad_if_needed = false, const std::vector<uint8_t> &fill_value = {0, 0, 0}, BorderType padding_mode = BorderType::kConstant)
Constructor.
说明
If the input image is more than one, then make sure that the image size is the same.
- 参数
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 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.
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.
样例/* Define operations */ auto decode_op = vision::Decode(); auto random_crop_op = vision::RandomCrop({255, 255}, {10, 10, 10, 10}); /* dataset is an instance of Dataset object */ dataset = dataset->Map({decode_op, random_crop_op}, // operations {"image"}); // input columns
-
~RandomCrop() = default
Destructor.
-
explicit RandomCrop(const std::vector<int32_t> &size, const std::vector<int32_t> &padding = {0, 0, 0, 0}, bool pad_if_needed = false, const std::vector<uint8_t> &fill_value = {0, 0, 0}, BorderType padding_mode = BorderType::kConstant)