<< GaussianBlur Image filtering blur >>

scicv >> Image filtering > Sobel

Sobel

Calculates the derivatives of an image

Syntax

img_out = Sobel(img_in, depth, dx, dy[, ksize[, scale[, delta[, borderType]]]])

Parameters

img_in

Input image (Mat).

depth

Depth of output image (double), -1 specifies the output image has the same depth as the input image.

dx

Order of the derivative x (double).

dy

Order of the derivative y (double).

ksize

Kernel size, can be 1,3,5 or 7 (default 3).

scale

Scale factor for the computed derivated values (double) (default 1).

delta

Value added to the filtered pixels (double) (default 0).

borderType

Pixel extrapolation methodd (double).

img_out

Output image (Mat).

Description

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.

Examples

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);

Report an issue
<< GaussianBlur Image filtering blur >>