1 | % DRAWEDGELIST - plots pixels in edgelists |
---|
2 | % |
---|
3 | % Usage: drawedgelist(edgelist, rowscols, randcol, figno) |
---|
4 | % |
---|
5 | % edgelist - Cell array of edgelists in the form |
---|
6 | % { [r1 c1 [r1 c1 etc } |
---|
7 | % ... |
---|
8 | % rN cN] ....] |
---|
9 | % rowscols - 2 element vector [rows cols] specifying the size of the |
---|
10 | % image from which edges were detected (used to set size |
---|
11 | % of plotted image) |
---|
12 | % randcol - Optional flag (1/0) to turn on/off random color coding for |
---|
13 | % each edgelist so that it is easier to see how the edges |
---|
14 | % have been broken up into separate lists. Default is 0. |
---|
15 | % figno - Optional figure number in which to display image. |
---|
16 | % |
---|
17 | % See also: EDGELINK, LINESEG |
---|
18 | |
---|
19 | % Copyright (c) 2003-2004 Peter Kovesi |
---|
20 | % School of Computer Science & Software Engineering |
---|
21 | % The University of Western Australia |
---|
22 | % http://www.csse.uwa.edu.au/ |
---|
23 | % |
---|
24 | % Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
25 | % of this software and associated documentation files (the "Software"), to deal |
---|
26 | % in the Software without restriction, subject to the following conditions: |
---|
27 | % |
---|
28 | % The above copyright notice and this permission notice shall be included in |
---|
29 | % all copies or substantial portions of the Software. |
---|
30 | % |
---|
31 | % The Software is provided "as is", without warranty of any kind. |
---|
32 | |
---|
33 | % February 2003 - Original version |
---|
34 | % September 2004 - Revised and updated |
---|
35 | |
---|
36 | function drawedgelist(edgelist, rowscols, randcol, figno) |
---|
37 | |
---|
38 | if nargin == 4 |
---|
39 | figure(figno); |
---|
40 | end |
---|
41 | |
---|
42 | if nargin == 2 |
---|
43 | randcol = 0; |
---|
44 | end |
---|
45 | |
---|
46 | Nedge = length(edgelist); |
---|
47 | |
---|
48 | if randcol |
---|
49 | colourmp = hsv(Nedge); % HSV colour map with Nedge entries |
---|
50 | colourmp = colourmp(randperm(Nedge),:); % Random permutation |
---|
51 | for I = 1:Nedge |
---|
52 | line(edgelist{I}(:,2), edgelist{I}(:,1),'color',colourmp(I,:)); |
---|
53 | end |
---|
54 | else |
---|
55 | for I = 1:Nedge |
---|
56 | line(edgelist{I}(:,2), edgelist{I}(:,1)); |
---|
57 | end |
---|
58 | end |
---|
59 | |
---|
60 | % Check whether we need to expand bounds |
---|
61 | |
---|
62 | minx = 1; miny = 1; |
---|
63 | maxx = rowscols(2); maxy = rowscols(1); |
---|
64 | |
---|
65 | for I = 1:Nedge |
---|
66 | minx = min(min(edgelist{I}(:,2)),minx); |
---|
67 | miny = min(min(edgelist{I}(:,1)),miny); |
---|
68 | maxx = max(max(edgelist{I}(:,2)),maxx); |
---|
69 | maxy = max(max(edgelist{I}(:,1)),maxy); |
---|
70 | end |
---|
71 | |
---|
72 | % axis([1 rowscols(2) 1 rowscols(1)]); |
---|
73 | axis([minx maxx miny maxy]); |
---|
74 | axis('equal'); axis('ij'); |
---|