Find edges in a single channel image.
E = edge(im, method) E = edge(im, method, thresh) E = edge(im, method, thresh, direction) E = edge(im, method, thresh, sigma) [E, thresh] = edge(im, method, ...)
Input image which must be a single channel image.
may be 'sobel'(default), 'prewitt', 'log', 'fftderiv' or 'canny'. Other methods will appear in the future.
sets the threshold level, from 0 to 1. Defaults to 0.2. If negative, then the output image, E , will have the un-thresholded gradient image.
may be 'horizontal', 'vertical' or 'both'(default). This determines the direction to compute the image gradient.
Controls the ammount of high-frequency attenuation in some methods (only the 'fftderiv' method uses this parameter). This can be used to obtain different levels of detail and to filter out high-frequency noise.
edge image which is boolean matrix and has the same size as im . If thresh<0 , E is a double un-thresholded image.
The function edge performs edge detection on a grayscale intensity image. The user may set the method, the threshold level, the direction of the edge detection, etc.
E=edge(im, 'sobel', thresh, direction) Detects edges in im , using the sobel gradient estimator.
E=edge(im, 'prewitt', thresh, direction) Detects edges in im , using the prewitt gradient estimator.
E=edge(im, 'log', thresh, sigma) Detects edges in im , using the the Laplacian of Gaussian method. sigma is the standard deviation of the LoG filter and the size of the LoG filter is nxn, where n = ceil(sigma*3)*2+1. The default value for sigma is 2.
E=edge(im, 'fftderiv', thresh, direction, sigma) Detects edges in im , using the FFT gradient method, default sigma 1.0
E=edge(im, 'canny', thresh, sigma) Detects edges in im , using Canny method. thresh is a two-element vector, in which the fist element is the low threshold and the seond one is the high threshold. If thresh is a scalar, the low threshold is 0.4*thresh and the high one is thresh . Besides, thresh can not be negative scalar. sigma is the Aperture parameter for canny operator, which must be 1, 3, 5 or 7. default thresh 0.2; default sigma 3.
Supported classes: INT8, UINT8, INT16, UINT16, INT32, DOUBLE.
im = imread(fullpath(getIPCVpath() + "/images/baboon.png")); im = rgb2gray(im); E = edge(im, 'sobel'); imshow(E); E = edge(im, 'canny', [0.06, 0.2]); imshow(E); E = edge(im, 'prewitt'); imshow(mat2gray(E)); | ![]() | ![]() |