Using Sobel operator with only 1D convolution

72 views Asked by At

The Sobel operator is using a separable kernel. That means that the Sobel operator can use 1D convolution vector multiplication instead of 2D convolution matrix multiplication. The 1D convolution vector multiplication requires less iteration compared to the 2D case.

Here is a working example how to do Sobel operation with conv2, assuming that X is a matrix of e.g a picture.

K_x = [-1 0 1; -2 0 2; -1 0 1];
K_y = [-1 -2 -1; 0 0 0; 1 2 1];

% Do conv2
Gx = conv2(X, K_x, 'same');
Gy = conv2(X, K_y, 'same');

% Compute the gradients
G = sqrt(Gx.^2 + Gy.^2);

% Compute the orientations
O = atan2d(Gy, Gx);

Question:

How should the kernel look like if I want to use the 1D conv command to compute the Sobel operator in Matlab?

0

There are 0 answers