Function mindspore::dataset::SubStractMeanNormalize

Function Documentation

bool mindspore::dataset::SubStractMeanNormalize(const LiteMat &src, LiteMat &dst, const std::vector<float> &mean, const std::vector<float> &std)

normalize image, currently the supports data type is float.

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_src2;
ConvertTo(lite_mat_src, lite_mat_src2);
LiteMat lite_mat_dst;

/* Normalize */
std::vector<float> means = {0.485, 0.456, 0.406};
std::vector<float> stds = {0.229, 0.224, 0.225};
SubStractMeanNormalize(lite_mat_src2, lite_mat_dst, means, stds);
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.

  • mean[in] Mean of the data set.

  • std[in] Norm of the data set.

返回

Return true if transform successfully.