Function mindspore::dataset::Crop

Function Documentation

bool mindspore::dataset::Crop(const LiteMat &src, LiteMat &dst, int x, int y, int w, int h)

crop image, the channel supports is 3 and 1.

Parameters
  • src[in] Input image data.

  • dst[in] Output image data.

  • x[in] The x coordinate value of the starting point of the screenshot.

  • y[in] The y coordinate value of the starting point of the screenshot.

  • w[in] The width of the screenshot.

  • h[in] The height of the screenshot.

Returns

Return true if transform successfully.

样例
/* 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;

/* Crop to (32, 32, 3) */
Crop(lite_mat_src, lite_mat_dst, 0, 0, 32, 32);
std::cout << lite_mat_dst.width_ << " " << lite_mat_dst.height_ << " " << lite_mat_dst.channel_ << std::endl;