Function mindspore::dataset::Pad

Function Documentation

bool mindspore::dataset::Pad(const LiteMat &src, LiteMat &dst, int top, int bottom, int left, int right, PaddBorderType pad_type, uint8_t fill_b_or_gray = 0, uint8_t fill_g = 0, uint8_t fill_r = 0)

padd image, the channel supports is 3 and 1.

Example
/* Assume p_rgb is a pointer that points to an image with shape (width, height, channel) */
LiteMat lite_mat_src(width, height, channel, (void *)p_rgb, LDataType::FLOAT32);
LiteMat lite_mat_dst;

/* Pad image with 4 pixels */
Pad(lite_mat_src, lite_mat_dst, 4, 4, 4, 4, PaddBorderType::PADD_BORDER_CONSTANT);
std::cout << lite_mat_dst.width_ << " " << lite_mat_dst.height_ << " " << lite_mat_dst.channel_ << std::endl;

参数
  • src[in] Input image data.

  • dst[in] Output image data.

  • top[in] The length of top.

  • bottom[in] The length of bottom.

  • left[in] The length of left.

  • right[in] he length of right.

  • pad_type[in] The type of pad.

    • PaddBorderType.PADD_BORDER_CONSTANT, fills the border with constant values.

    • PaddBorderType.PADD_BORDER_REPLICATE, fills the border with replicate mode.

    • PaddBorderType.PADD_BORDER_REFLECT_101, fills the border with reflect 101 mode.

    • PaddBorderType.PADD_BORDER_DEFAULT, default pad mode, use reflect 101 mode.

  • fill_b_or_gray[in] B or GRAY.

  • fill_g[in] G.

  • fill_r[in] R.

返回

Return true if transform successfully.