Home > freetb4matlab > image > edge.m

edge

PURPOSE ^

% Detect edges in the given image using various methods. The first input @var{im}

SYNOPSIS ^

function [bw, out_threshold, g45_out, g135_out] = edge (im, method, varargin)

DESCRIPTION ^

% -*- texinfo -*-
% @deftypefn {Function File} {@var{bw} =} edge (@var{im}, @var{method})
% @deftypefnx{Function File} {@var{bw} =} edge (@var{im}, @var{method}, @var{arg1}, @var{arg2})
% @deftypefnx{Function File} {[@var{bw}, @var{thresh}] =} edge (...)
% Detect edges in the given image using various methods. The first input @var{im}
% is the gray scale image in which edges are to be detected. The second argument
% controls which method is used for detecting the edges. The rest of the input
% arguments depend on the selected method. The first output @var{bw} is a 
% @code{logical} image containing the edges. Most methods also returns an automatically
% computed threshold as the second output.
%
% The @var{method} input argument can any of the following strings (the default
% value is 'Sobel')
%
% @table @asis
% @item 'Sobel'
% Finds the edges in @var{im} using the Sobel approximation to the
% derivatives. Edge points are defined as points where the length of
% the gradient exceeds a threshold and is larger than it's neighbours
% in either the horizontal or vertical direction. The threshold is passed to
% the method in the third input argument @var{arg1}. If one is not given, a
% threshold is automatically computed as 4*@math{M}, where @math{M} is the mean
% of the gradient of the entire image. The optional 4th input argument controls
% the direction in which the gradient is approximated. It can be either
% 'horizontal', 'vertical', or 'both' (default).
%
% @item 'Prewitt'
% Finds the edges in @var{im} using the Prewitt approximation to the
% derivatives. This method works just like 'Sobel' except a different aproximation
% the gradient is used.
%
% @item 'Roberts'
% Finds the edges in @var{im} using the Roberts approximation to the
% derivatives. Edge points are defined as points where the length of
% the gradient exceeds a threshold and is larger than it's neighbours
% in either the horizontal or vertical direction. The threshold is passed to
% the method in the third input argument @var{arg1}. If one is not given, a
% threshold is automatically computed as 6*@math{M}, where @math{M} is the mean
% of the gradient of the entire image. The optional 4th input argument can be
% either 'thinning' (default) or 'nothinning'. If it is 'thinning' a simple
% thinning procedure is applied to the edge image such that the edges are only
% one pixel wide. If @var{arg2} is 'nothinning', this procedure is not applied.
%
% @item 'Kirsch'
% Finds the edges in @var{im} using the Kirsch approximation to the
% derivatives. Edge points are defined as points where the length of
% the gradient exceeds a threshold and is larger than it's neighbours
% in either the horizontal or vertical direction. The threshold is passed to
% the method in the third input argument @var{arg1}. If one is not given, a
% threshold is automatically computed as @math{M}, where @math{M} is the mean
% of the gradient of the entire image. The optional 4th input argument controls
% the direction in which the gradient is approximated. It can be either
% 'horizontal', 'vertical', or 'both' (default).
%
% @item 'LoG'
% Finds edges in @var{im} by convolving with the Laplacian of Gaussian (LoG)
% filter, and finding zero crossings. Only zero crossings where the 
% filter response is larger than an automatically computed threshold are retained.
% The threshold is passed to the method in the third input argument @var{arg1}.
% If one is not given, a threshold is automatically computed as 0.75*@math{M},
% where @math{M} is the mean of absolute value of LoG filter response. The
% optional 4th input argument sets the spread of the LoG filter. By default
% this value is 2.
%
% @item 'Zerocross'
% Finds edges in the image @var{im} by convolving it with the user-supplied filter
% @var{arg2} and finding zero crossings larger than the threshold @var{arg1}. If
% @var{arg1} is [] a threshold is computed as the mean value of the absolute
% filter response.
%
% @item 'Canny'
% Finds edges using the Canny edge detector. The optional third input argument
% @var{arg1} sets the thresholds used in the hysteresis thresholding. If 
% @var{arg1} is a two dimensional vector it's first element is used as the lower
% threshold, while the second element is used as the high threshold. If, on the
% other hand, @var{arg1} is a single scalar it is used as the high threshold,
% while the lower threshold is 0.4*@var{arg1}. The optional 4th input argument
% @var{arg2} is the spread of the low-pass Gaussian filter that is used to smooth
% the input image prior to estimating gradients. By default this scale parameter
% is 2.
%
% @item 'Lindeberg'
% Finds edges using in @var{im} using the differential geometric single-scale edge
% detector given by Tony Lindeberg. The optional third input argument @var{arg1}
% is the scale (spread of Gaussian filter) at which the edges are computed. By
% default this 2.
%
% @item 'Andy'
% A.Adler's idea (c) 1999. Somewhat based on the canny method. The steps are
% @enumerate
% @item
% Do a Sobel edge detection and to generate an image at
% a high and low threshold.
% @item
% Edge extend all edges in the LT image by several pixels,
% in the vertical, horizontal, and 45 degree directions.
% Combine these into edge extended (EE) image.
% @item
% Dilate the EE image by 1 step.
% @item
% Select all EE features that are connected to features in
% the HT image.
% @end enumerate
% 
% The parameters for the method is given in a vector:
% @table @asis
% @item params(1)==0 or 4 or 8
% Perform x connected dilatation (step 3).
% @item params(2)
% Dilatation coeficient (threshold) in step 3.
% @item params(3)
% Length of edge extention convolution (step 2).
% @item params(4)
% Coeficient of extention convolution in step 2.
% @end table
% defaults = [8, 1, 3, 3]
%
% @end table
%
% @seealso{fspecial, nonmax_supress}
% @end deftypefn

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Sat 16-May-2009 00:04:49 by m2html © 2003