Function mindspore::dataset::WarpPerspectiveBilinear

Function Documentation

bool mindspore::dataset::WarpPerspectiveBilinear(const LiteMat &src, LiteMat &dst, const LiteMat &M, int dst_w, int dst_h, PaddBorderType borderType, std::vector<uint8_t> &borderValue)

affine image by linear.

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::UINT8);
LiteMat lite_mat_dst;

/* Get Perspective matrix and apply */
std::vector<Point> src = {Point(165, 270), Point(835, 270), Point(360, 125), Point(615, 125)};
std::vector<Point> dst = {Point(165, 270), Point(835, 270), Point(100, 100), Point(500, 30)};
LiteMat M;
GetPerspectiveTransform(src, dst, M);
std::vector<uint8_t> border_value = {0, 0, 0};
WarpPerspectiveBilinear(lite_mat_src, lite_mat_dst, M, width, height,
                        PaddBorderType::PADD_BORDER_CONSTANT, border_value);
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.

  • M[in] Transformation matrix

  • dst_w[in] The width of the output image.

  • dst_h[in] The height of the output image.

  • borderType[in] Edge processing type.

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

  • borderValue[in] Boundary fill value.

返回

Return true if transform successfully.