⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 maxlinedev.m

📁 这个源代码是用于边缘连接和线性拟合使用matlab写的
💻 M
字号:
% MAXLINEDEV - Find max deviation from a line in an edge contour.%% Function finds the point of maximum deviation from a line joining the% endpoints of an edge contour.%% Usage:   [maxdev, index, D, totaldev] = maxlinedev(x,y)%% Arguments:%          x, y   - arrays of x,y  (col,row) indicies of pixels on the%                   contour.% Returns:%          maxdev   - Maximum deviation of contour point from the line%                     joining the end points of the contour (pixels).%          index    - Index of the point having maxdev.%          D        - Distance between end points of the contour so that%                     one can calculate maxdev/D - the normalised error.%          totaldev - Sum of the distances of all the pixels from the%                     line joining the endpoints.%% See also:  EDGELINK, LINESEG, MERGESEG, DRAWSEG%% Peter Kovesi  % School of Computer Science & Software Engineering% The University of Western Australia% pk @ csse uwa edu au% http://www.csse.uwa.edu.au/~pk%% December 2000 - Original version% February 2003 - Added calculation of total deviationfunction [maxdev, index, D, totaldev] = maxlinedev(x,y)    Npts = length(x);        if Npts == 1	warning('Contour of length 1');	maxdev = 0; index = 1;	D = 1;	return;    elseif Npts == 0	error('Contour of length 0');    end        % Eqn of line joining end pts (x1 y1) and (x2 y2) can be parameterised by    %        %    x*(y1-y2) + y*(x2-x1) + y2*x1 - y1*x2 = 0    %    % (See Jain, Rangachar and Schunck, "Machine Vision", McGraw-Hill    % 1996. pp 194-196)            y1my2 = y(1)-y(Npts);                       % Pre-compute parameters    x2mx1 = x(Npts)-x(1);    C = y(Npts)*x(1) - y(1)*x(Npts);        D = norm([x(1) y(1)] - [x(Npts) y(Npts)]);  % Distance between end points        d = abs(x*y1my2 + y*x2mx1 + C)/D;           % Distance from line                                                % segment for each                                                % contour point    [maxdev, index] = max(d);    totaldev = sum(d.^2);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -