Function mindspore::dataset::Canny

Function Documentation

bool mindspore::dataset::Canny(const LiteMat &src, LiteMat &dst, double low_thresh, double high_thresh, int ksize = 3, bool L2gradient = false)

Detect edges in an image.

Example
/* Assume p_rgb is a pointer that points to an image with shape (width, height, channel) */
LiteMat lite_mat_src;
InitFromPixel(p_rgb, LPixelType::RGB, LDataType::UINT8, width, height, lite_mat_src);
LiteMat lite_mat_src2;
ConvertRgbToGray(lite_mat_src, LDataType::UINT8, image.cols, image.rows, lite_mat_src2);

LiteMat lite_mat_dst;
Canny(lite_mat_src2, lite_mat_dst, 200, 300, 5);
std::cout << lite_mat_dst.width_ << " " << lite_mat_dst.height_ << " " << lite_mat_dst.channel_ << std::endl;

Parameters
  • src[in] LiteMat image to be processed. Only single channel LiteMat of type UINT8 is supported now.

  • dst[in] LiteMat image after processing.

  • low_thresh[in] The lower bound of the edge. Pixel with value below it will not be considered as a boundary. It should be a nonnegative value.

  • high_thresh[in] The higher bound of the edge. Pixel with value over it will be absolutely considered as a boundary. It should be a nonnegative value and no less than low_thresh.

  • ksize[in] The size of Sobel kernel (default=3). It can only be 3, 5 or 7.

  • L2gradient[in] Whether to use L2 distance while calculating gradient (default=false).

Returns

Return true if transform successfully.