Calculates the derivatives of an image
img_out = Sobel(img_in, depth, dx, dy[, ksize[, scale[, delta[, borderType]]]])
Input image (Mat).
Depth of output image (double), -1 specifies the output image has the same depth as the input image.
Order of the derivative x (double).
Order of the derivative y (double).
Kernel size, can be 1,3,5 or 7 (default 3).
Scale factor for the computed derivated values (double) (default 1).
Value added to the filtered pixels (double) (default 0).
Pixel extrapolation methodd (double).
Output image (Mat).
sobel calculates the derivatives of a given order (up to 7), on a specific direction (or both directions), of an image using the Sobel operator.
scicv_Init(); img = imread(getSampleImage("lena.jpg")); ksize = 3; // First order derivative on x dx = 1; dy = 0; img_grad_x = Sobel(img, CV_16S, dx, dy, ksize); subplot(1,2,1); matplot(img_grad_x); // First order derivative on y dx = 0; dy = 1; img_grad_y = Sobel(img, CV_16S, dx, dy, ksize); subplot(1,2,2); matplot(img_grad_y); delete_Mat(img); delete_Mat(img_grad_x); delete_Mat(img_grad_y); | ![]() | ![]() |