Function mindspore::dataset::Sobel

Function Documentation

bool mindspore::dataset::Sobel(const LiteMat &src, LiteMat &dst, int flag_x, int flag_y, int ksize = 3, double scale = 1.0, PaddBorderType pad_type = PaddBorderType::PADD_BORDER_DEFAULT)

Filter the image by a Sobel kernel.

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

  • dst[in] LiteMat image after processing.

  • flag_x[in] Order of the derivative x. It should be a nonnegative value and can not be equal to 0 at the same time with flag_y.

  • flag_y[in] Order of the derivative y. It should be a nonnegative value and can not be equal to 0 at the same time with flag_x.

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

  • scale[in] The scale factor for the computed derivative values (default=1.0).

  • pad_type[in] The padding type used while filtering (default=PaddBorderType::PADD_BORDER_DEFAULT).

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

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;
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;
Sobel(lite_mat_src2, lite_mat_dst, 1, 0, 3, 1, PaddBorderType::PADD_BORDER_REPLICATE);
std::cout << lite_mat_dst.width_ << " " << lite_mat_dst.height_ << " " << lite_mat_dst.channel_ << std::endl;