Name

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, direction, sigma)

Parameters

E
Resulting image.
Img
M x N Grayscale (intensity) image in any range.
method
may be 'sobel'(default), 'prewitt' or 'fftderiv'. Other methods will appear in the future.
thresh
sets the threshold level, from 0 to 1. Defaults to 0.5. If negative, then the output image, E, will have the un-thresholded gradient image.
direction
may be 'horizontal', 'vertical' or 'both'(default). This determines the direction to compute the image gradient.
sigma
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. Defaults to 1.
<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.

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);
   xbasc()
   imshow(Img);

   e = edge(Img);  // sobel, thresh = 0.5
   xbasc()
   imshow(e,2)

   e = edge(Img,'prewitt'); // thresh = 0.5
   xbasc()
   imshow(e,2)

   e = edge(Img,'fftderiv', 0.4);  // FFT gradient method; 0.4 threshold
   xbasc()
   imshow(e,[])

   // It is useful to thin the edges, eliminating redundant pixels:
   e = thin(e);
   xbasc()
   imshow(e,[])

   e = edge(Img,'fftderiv',sigma=3,thresh=-1); // thicker edges, no threshold
   xbasc()
   imshow(e,[])

   e = edge(Img,thresh=-1);
   xbasc()
   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

Ricardo Fabbri <ricardofabbri[at]users.sf.net>

Availability

The latest version of SIP can be found at

http://siptoolbox.sf.net

See Also

bwborder , mogrify , getangle , imconv , im2gray , mkfilter