function [eout,thresh,gv_45,gh_135] = edge(varargin)
%EDGE Find edges in intensity image.
% EDGE takes an intensity or a binary image I as its input, and returns a
% binary image BW of the same size as I, with 1's where the function
% finds edges in I and 0's elsewhere.
%
% EDGE supports six different edge-finding methods:
%
% The Sobel method finds edges using the Sobel approximation to the
% derivative. It returns edges at those points where the gradient of
% I is maximum.
%
% The Prewitt method finds edges using the Prewitt approximation to
% the derivative. It returns edges at those points where the gradient
% of I is maximum.
%
% The Roberts method finds edges using the Roberts approximation to
% the derivative. It returns edges at those points where the gradient
% of I is maximum.
%
% The Laplacian of Gaussian method finds edges by looking for zero
% crossings after filtering I with a Laplacian of Gaussian filter.
%
% The zero-cross method finds edges by looking for zero crossings
% after filtering I with a filter you specify.
%
% The Canny method finds edges by looking for local maxima of the
% gradient of I. The gradient is calculated using the derivative of a
% Gaussian filter. The method uses two thresholds, to detect strong
% and weak edges, and includes the weak edges in the output only if
% they are connected to strong edges. This method is therefore less
% likely than the others to be "fooled" by noise, and more likely to
% detect true weak edges.
%
% The parameters you can supply differ depending on the method you
% specify. If you do not specify a method, EDGE uses the Sobel method.
%
% Sobel Method
% ------------
% BW = EDGE(I,'sobel') specifies the Sobel method.
%
% BW = EDGE(I,'sobel',THRESH) specifies the sensitivity threshold for
% the Sobel method. EDGE ignores all edges that are not stronger than
% THRESH. If you do not specify THRESH, or if THRESH is empty ([]),
% EDGE chooses the value automatically.
%
% BW = EDGE(I,'sobel',THRESH,DIRECTION) specifies directionality for the
% Sobel method. DIRECTION is a string specifying whether to look for
% 'horizontal' or 'vertical' edges, or 'both' (the default).
%
% BW = EDGE(I,'sobel',...,OPTIONS) provides an optional string
% input. String 'nothinning' speeds up the operation of the algorithm by
% skipping the additional edge thinning stage. By default, or when
% 'thinning' string is specified, the algorithm applies edge thinning.
%
% [BW,thresh] = EDGE(I,'sobel',...) returns the threshold value.
%
% [BW,thresh,gv,gh] = EDGE(I,'sobel',...) returns vertical and
% horizontal edge responses to Sobel gradient operators. You can
% also use these expressions to obtain gradient responses:
% if ~(isa(I,'double') || isa(I,'single')); I = im2single(I); end
% gh = imfilter(I,fspecial('sobel') /8,'replicate'); and
% gv = imfilter(I,fspecial('sobel')'/8,'replicate');
%
% Prewitt Method
% --------------
% BW = EDGE(I,'prewitt') specifies the Prewitt method.
%
% BW = EDGE(I,'prewitt',THRESH) specifies the sensitivity threshold for
% the Prewitt method. EDGE ignores all edges that are not stronger than
% THRESH. If you do not specify THRESH, or if THRESH is empty ([]),
% EDGE chooses the value automatically.
%
% BW = EDGE(I,'prewitt',THRESH,DIRECTION) specifies directionality for
% the Prewitt method. DIRECTION is a string specifying whether to look
% for 'horizontal' or 'vertical' edges, or 'both' (the default).
%
% BW = EDGE(I,'prewitt',...,OPTIONS) provides an optional string
% input. String 'nothinning' speeds up the operation of the algorithm by
% skipping the additional edge thinning stage. By default, or when
% 'thinning' string is specified, the algorithm applies edge thinning.
%
% [BW,thresh] = EDGE(I,'prewitt',...) returns the threshold value.
%
% [BW,thresh,gv,gh] = EDGE(I,'prewitt',...) returns vertical and
% horizontal edge responses to Prewitt gradient operators. You can
% also use these expressions to obtain gradient responses:
% if ~(isa(I,'double') || isa(I,'single')); I = im2single(I); end
% gh = imfilter(I,fspecial('prewitt') /6,'replicate'); and
% gv = imfilter(I,fspecial('prewitt')'/6,'replicate');
%
% Roberts Method
% --------------
% BW = EDGE(I,'roberts') specifies the Roberts method.
%
% BW = EDGE(I,'roberts',THRESH) specifies the sensitivity threshold for
% the Roberts method. EDGE ignores all edges that are not stronger than
% THRESH. If you do not specify THRESH, or if THRESH is empty ([]),
% EDGE chooses the value automatically.
%
% BW = EDGE(I,'roberts',...,OPTIONS) provides an optional string
% input. String 'nothinning' speeds up the operation of the algorithm by
% skipping the additional edge thinning stage. By default, or when
% 'thinning' string is specified, the algorithm applies edge thinning.
%
% [BW,thresh] = EDGE(I,'roberts',...) returns the threshold value.
%
% [BW,thresh,g45,g135] = EDGE(I,'roberts',...) returns 45 degree and
% 135 degree edge responses to Roberts gradient operators. You can
% also use these expressions to obtain gradient responses:
% if ~(isa(I,'double') || isa(I,'single')); I = im2single(I); end
% g45 = imfilter(I,[1 0; 0 -1]/2,'replicate'); and
% g135 = imfilter(I,[0 1;-1 0]/2,'replicate');
%
% Laplacian of Gaussian Method
% ----------------------------
% BW = EDGE(I,'log') specifies the Laplacian of Gaussian method.
%
% BW = EDGE(I,'log',THRESH) specifies the sensitivity threshold for the
% Laplacian of Gaussian method. EDGE ignores all edges that are not
% stronger than THRESH. If you do not specify THRESH, or if THRESH is
% empty ([]), EDGE chooses the value automatically.
%
% BW = EDGE(I,'log',THRESH,SIGMA) specifies the Laplacian of Gaussian
% method, using SIGMA as the standard deviation of the LoG filter. The
% default SIGMA is 2; the size of the filter is N-by-N, where
% N=CEIL(SIGMA*3)*2+1.
%
% [BW,thresh] = EDGE(I,'log',...) returns the threshold value.
%
% Zero-cross Method
% -----------------
% BW = EDGE(I,'zerocross',THRESH,H) specifies the zero-cross method,
% using the specified filter H. If THRESH is empty ([]), EDGE chooses
% the sensitivity threshold automatically.
%
% [BW,THRESH] = EDGE(I,'zerocross',...) returns the threshold value.
%
% Canny Method
% ----------------------------
% BW = EDGE(I,'canny') specifies the Canny method.
%
% BW = EDGE(I,'canny',THRESH) specifies sensitivity thresholds for the
% Canny method. THRESH is a two-element vector in which the first element
% is the low threshold, and the second element is the high threshold. If
% you specify a scalar for THRESH, this value is used for the high
% threshold and 0.4*THRESH is used for the low threshold. If you do not
% specify THRESH, or if THRESH is empty ([]), EDGE chooses low and high
% values automatically.
%
% BW = EDGE(I,'canny',THRESH,SIGMA) specifies the Canny method, using
% SIGMA as the standard deviation of the Gaussian filter. The default
% SIGMA is 1; the size of the filter is chosen automatically, based
% on SIGMA.
%
% [BW,thresh] = EDGE(I,'canny',...) returns the threshold values as a
% two-element vector.
%
% Class Support
% -------------
% I is a nonsparse numeric array. BW is of class logical.
%
% Remarks
% -------
% For the 'log' and 'zerocross' methods, if you specify a
% threshold of 0, the output image has closed contours, because
% it includes all of the zero crossings in the input image.
%
% Example
% -------
% Find the edges of the circuit.tif image using the Prewitt and Canny
% methods:
%
% I = imread('circuit.tif');
没有合适的资源?快使用搜索试试~ 我知道了~
边缘检测所需的matlab函数
共3个文件
m:3个
需积分: 18 12 下载量 144 浏览量
2009-05-18
10:49:12
上传
评论
收藏 15KB RAR 举报
温馨提示
边缘检测所需的matlab函数 包括edge、fspecial、imfilter函数
资源推荐
资源详情
资源评论
收起资源包目录
MATLAB函数.rar (3个子文件)
fspecial.m 13KB
edge.m 25KB
imfilter.m 14KB
共 3 条
- 1
资源评论
jaylong8733
- 粉丝: 2
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功