<< drawline SIP - Scilab Image Processing Toolbox edilate >>

SIP - Scilab Image Processing Toolbox >> SIP - Scilab Image Processing Toolbox > edge

edge

Edge detection

Calling Sequence

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, ...)

Parameters

Img
M x N Grayscale (intensity) image in any range.
method
may be 'sobel'(default), 'prewitt' 'fftderiv' or 'canny'. SIVP (a fork of SIP) also provides 'LoG'. Other methods will appear in the future.
thresh
sets the threshold level, from 0 to 1, except for the Canny method. Defaults to 0.5. If negative, then the output image, 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*thresh and 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.
direction
may be 'horizontal', 'vertical' or 'both'(default). This determines the direction to compute the image gradient.
sigma or kernel width
Controls the ammount of high-frequency attenuation in some methods, and can be used to obtain different levels of detail and to filter out noise. This is the sigma of the Gaussian filter for the 'fftderiv' method, for which it defaults to 1. For the Canny method, this means the Sobel kernel size (width) and must be 3, 5 or 7.
<named_args>
This is a sequence of statements key1=value1, key2=value2,... where key1, key2,... can be any of the optional arguments above, in any order.
E
Resulting image.

Description

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.

edge(Img)
Detects edges in 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.

Examples

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

References

"Shape Analysis and Classification", L. da F. Costa and R. M. Cesar Jr., CRC Press, section 3.3.

Authors

Availability

The latest version of SIP can be found at

http://siptoolbox.sf.net

See Also


<< drawline SIP - Scilab Image Processing Toolbox edilate >>