E = edge(Img)
E = edge(Img, <named_args>)
E = edge(Img, method)
E = edge(Img, method, thresh)
E = edge(Img, method, thresh, direction)
E = edge(Img, method, thresh, sigma)
[E, thresh] = edge(im, method, ...)
E, will have the un-thresholded gradient image. For the Canny method, this is a two-element vector where the first element is the low threshold and the second one is the high threshold defining the weak and strong edges, respectively. If this is a scalar in Canny, the low threshold is
0.4*threshand the high threshold is just
thresh. For Canny, thresholds cannot be a negative scalar and are always relative to the highest internally computed gradient magnitude of the image. The best way to find a good threshold is by trial and error (e.g., binary searching). Future methods will appear in the future.
The function edge performs edge detection on a grayscale intensity image. The user may set the method, the threshold level and the direction of the edge detection.
Img, using the sobel gradient estimator, 0.5 threshold level and in both horizontal and vertical directions.
The other parameters are optional and non-positional. That is, they may be passed to the function by their name. The following example illustrates this.
initial_dir = PWD; chdir (SIPDIR + 'images'); Img = imread('tru.jpg'); Img = im2gray(Img); clf imshow(Img); e = edge(Img); // sobel, thresh = 0.5 clf imshow(e,2) e = edge(Img, 'prewitt'); // thresh = 0.5 clf imshow(e,2) e = edge(Img, 'canny', [0.06 0.2]); clf imshow(e,2) e = edge(Img, 'fftderiv', 0.4); // FFT gradient method; 0.4 threshold clf imshow(e,) // It is useful to thin the edges, eliminating redundant pixels: e = thin(e); clf imshow(e,) e = edge(Img,'fftderiv',sigma=3,thresh=-1); // thicker edges, no threshold clf imshow(e,) e = edge(Img,thresh=-1); clf imshow(e,) chdir(initial_dir);
"Shape Analysis and Classification", L. da F. Costa and R. M. Cesar Jr., CRC Press, section 3.3.