Function mindspore::dataset::ConvertRgbToGray

Function Documentation

bool mindspore::dataset::ConvertRgbToGray(const LiteMat &src, LDataType data_type, int w, int h, LiteMat &mat)

Convert RGB image or color image to grayscale image.

Parameters
  • src[in] Input image data.

  • data_type[in] The type of data (refer to LDataType class).

  • w[in] The width of output image.

  • h[in] The height of output image.

  • mat[in] Output image data.

Returns

Return true if transform successfully.

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

ConvertRgbToGray(lite_mat_src, LDataType::UINT8, width, height, lite_mat_dst);
std::cout << lite_mat_dst.width_ << " " << lite_mat_dst.height_ << " " << lite_mat_dst.channel_ << std::endl;