www.gusucode.com > 实现边缘连接和线段拟合源码MATLAB实现源码程序 > Edgelink_/drawseg.m

    % DRAWSEG - Draws a series of line segments stored in an Nx4 array.
%
% Usage: drawseg(seglist, figNo, lw, col);
%                            
%         seglist - an Nx4 array storing line segments in the form
%                    [x1 y1 x2 y2
%                     x1 y1 x2 y2
%                         . .     ] etc 
%         figNo   - optional figure number
%         lw      - optional line width
%         col     - optional 3-vector specifying the colour
%
%
% See also:  EDGELINK, LINESEG, MAXLINEDEV, MERGESEG
%

% Copyright (c) 2000-2005 Peter Kovesi
% School of Computer Science & Software Engineering
% The University of Western Australia
% http://www.csse.uwa.edu.au/
% 
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
% in the Software without restriction, subject to the following conditions:
% 
% The above copyright notice and this permission notice shall be included in 
% all copies or substantial portions of the Software.
%
% The Software is provided "as is", without warranty of any kind.

% December 2000

function drawseg(seglist, figNo, lw, col);
    
    if nargin >= 2  
	figure(figNo);
    end
    
    if nargin < 3
	lw = 1;
	col = [0 0 1];
    elseif nargin < 4
	col = [0 0 1];
    end
    clf

    Nseg = size(seglist,1);

    hold on
    for s = 1:Nseg
	line([seglist(s,1) seglist(s,3)], [seglist(s,2) seglist(s,4)],...
	     'LineWidth',lw, 'Color',col);
	hold on
	plot([seglist(s,1) seglist(s,3)], [seglist(s,2) seglist(s,4)],'.'); 

    end
    
    axis('equal'), axis('ij')