# 边缘检测——数字图像处理实验

• r1_990881
了解作者
• 14.9KB
文件大小
• rar
文件格式
• 0
收藏次数
• VIP专享
资源类型
• 0
下载次数
• 2022-04-01 15:46
上传日期

• can
• fspecial.m
13.2KB
• edge.m
25.2KB
• imfilter.m
14.3KB

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

相关推荐
• 基于灰度图像的书体图像处理
基于灰度图像，可将raw格式转为bmp格式，对bmp格式文件进行线性拉伸、中值滤波、平移、缩放、转置等几何处理，可对图像基于sobel prewitt robert算子进行边缘检测，实现直方图均衡化，基于状态法（峰值法）、判断...
• VS2010多文档图像处理所有基础程序
利用VS2010编写的多文档的图像处理基础程序，包括灰度变换 直方图均衡 局部平均平滑 中值滤波 理想低通滤波 Butterworth低通滤波 图象锐化 理想高通滤波 Butterworth高通滤波 伪彩色增强 运动模糊 运动模糊复原 逆...
• 图像处理基本方法源代码
1.bmp图像读写； 2.几何变换：竖直镜像、水平镜像、对角镜像； 3.空间变换：傅里叶变换、沃尔什变换、离散余弦变换； 4.图像复原：均值滤波、中值滤波、高斯滤波； 5.图像增强：二值化、灰度化、直方图均衡化、伪...
• 经典图像处理源代码
Roberts边缘检测，Sobel边缘算法，LoG边缘算法，均值，中值滤波等等...
• 图像处理算法源程序
图像处理算法的源程序，C++，包括： 对图像进行二值化处理的源代码 对图像进行对角镜像处理（几何变换）的源代码 对图像进行离散余弦变换处理（图像变换）的源代码 对图像进行傅立叶变换处理（图像变换）的源代码 ...
• 特征提取与图像处理（2版）
特征提取与图像处理（2版），Mark S.Nixon, Alberto S.Aguado著，实英 杨高波译。
• 数字图像处理源程序
图像滤波 图像锐化 高斯模版 各种处理图像的算子（canny算子，robert算子）
• 数字图像处理实验4代码
与采用均值滤波法的处理结果进行比较。 5) 对指定图象A2或B2进行简单锐化（简单梯度算法、ROBERT算子），将原始图象及增强后的图象都显示于屏幕上，比较增强的效果。 6) 对指定图象A2或B2分别使用如下算子进行...
• 图像处理所有基础程序
图像显示： Bayer抖动显示 Floyd-Steinberg抖动显示 图像增强： 灰度变换 直方图均衡 局部平均平滑 中值滤波 理想低通滤波 Butterworth低通滤波 图象锐化 理想高通滤波 Butterworth高通滤波 伪彩色增强 图像复原：...
• SIM800C_MQTT.rar
使用SIM800C模块，使用MQTT协议，连接中国移动onenet平台，能实现数据的订阅、发布、存储等