This is a static copy of a profile report

Home

bwfill (15112 calls, 23.052 sec)
Generated 05-Nov-2014 07:52:50 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/images/images/bwfill.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
preprocessfunction7556
bwfillfunction7556
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
96
Ip = padarray(I,[1 1],1,'both'...
75566.189 s26.8%
75
J = padarray(J, [1 1], 0, 'bot...
75565.628 s24.4%
114
J = bwfillc(Ip, idxList, style...
75563.925 s17.0%
67
[xdata,ydata,I,xi,yi,r,c,style...
151122.564 s11.1%
81
J = ~J | I;
75560.861 s3.7%
All other lines  3.885 s16.9%
Totals  23.052 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
padarrayfunction1511211.576 s50.2%
images/private/bwfillcMEX-file75563.775 s16.4%
bwfill>ParseInputssubfunction151122.323 s10.1%
bwfillfunction75560 s0%
Self time (built-ins, overhead, etc.)  5.377 s23.3%
Totals  23.052 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
[ Show coverage for parent directory ]
Total lines in function165
Non-code lines (comments, blank lines)99
Code lines (lines that can run)66
Code lines that did run33
Code lines that did not run33
Coverage (did run/can run)50.00 %
Function listing
   time   calls  line
1 function varargout = bwfill(varargin)
2 %BWFILL Fill background regions in binary image.
3 %
4 % BWFILL is not recommended. Use IMFILL instead.
5 %
6 % BW2 = BWFILL(BW1,C,R,N) performs a flood-fill operation on
7 % the input binary image BW1, starting from the pixel (R,C). If
8 % R and C are equal-length vectors, the fill is performed in
9 % parallel from the starting locations (R(k),C(k)). N can have
10 % a value of either 4 or 8 (the default), where 4 specifies
11 % 4-connected foreground and 8 specifies 8-connected
12 % foreground. The foreground of BW1 comprises the "on" pixels
13 % (i.e., having value of 1).
14 %
15 % BW2 = BWFILL(BW1,N) displays the image BW1 on the screen and
16 % lets you select the starting points using the mouse. If you
17 % omit BW1, BWFILL operates on the image in the current
18 % axes. Use normal button clicks to add points. Press
19 % <BACKSPACE> or <DELETE> to remove the previously selected
20 % point. A shift-click, right-click, or double-click selects
21 % a final point and then starts the fill; pressing <RETURN>
22 % finishes the selection without adding a point.
23 %
24 % [BW2,IDX] = BWFILL(...) returns the linear indices of all
25 % pixels filled by BWFILL.
26 %
27 % BW2 = BWFILL(X,Y,BW1,Xi,Yi,N) uses the vectors X and Y to
28 % establish a nondefault spatial coordinate system for BW1. Xi
29 % and Yi are scalars or equal-length vectors that specify
30 % locations in this coordinate system.
31 %
32 % [X,Y,BW2,IDX,Xi,Yi] = BWFILL(...) returns the XData and YData
33 % in X and Y; the output image in BW2; linear indices of all
34 % filled pixels in IDX; and the fill starting points in Xi and
35 % Yi.
36 %
37 % BW2 = BWFILL(BW1,'holes',N) fills the holes in the binary
38 % image BW1. BWFILL automatically determines which pixels are
39 % in object holes, and then changes the value of those pixels
40 % from 0 to 1. N defaults to 8 if you omit the argument.
41 %
42 % [BW2,IDX] = BWFILL(BW1,'holes',N) returns the linear indices
43 % of all pixels filled in by BWFILL.
44 %
45 % If BWFILL is used with no output arguments, the resulting
46 % image is displayed in a new figure.
47 %
48 % Remarks
49 % -------
50 % BWFILL differs from many other binary image operations in
51 % that it operates on background pixels, rather than foreground
52 % pixels. If the foreground is 8-connected, the background is
53 % 4-connected, and vice versa. Note, however, that you specify
54 % the connectedness of the foreground when you call BWFILL.
55 %
56 % Class Support
57 % -------------
58 % The input image BW1 must be a numeric or logical matrix. The output
59 % image BW2 is logical.
60 %
61 % See also BWSELECT, IMFILL, ROIFILL.
62
63 % Copyright 1993-2011 The MathWorks, Inc.
64 % $Revision: 1.31.4.9.2.1 $ $Date: 2011/07/18 00:32:47 $
65
0.11 15112 66 try
2.56 15112 67 [xdata,ydata,I,xi,yi,r,c,style,newFig,fillHoles] = ParseInputs(varargin{:});
68 catch ME
69 rethrow(ME);
70 end
71
0.06 15112 72 if (fillHoles)
73 % special type of fill
0.03 7556 74 J = I;
5.63 7556 75 J = padarray(J, [1 1], 0, 'both');
0.04 7556 76 [M,N] = size(J);
0.18 7556 77 rSeeds = [1:M ones(1,N) 1:M M*ones(1,N)];
0.16 7556 78 cSeeds = [ones(1,M) 1:N N*ones(1,M) 1:N];
0.11 7556 79 J = bwfill(J, cSeeds, rSeeds, style);
0.40 7556 80 J = J(2:end-1,2:end-1);
0.86 7556 81 J = ~J | I;
82
0.06 7556 83 if (nargout > 0)
0.09 7556 84 varargout{1} = J;
0.05 7556 85 if (nargout > 1)
86 varargout{2} = find(J & ~I);
87 end
88 else
89 imshow(J);
90 end
91
0.04 7556 92 return
93 end
94
0.02 7556 95 [M,N] = size(I);
6.19 7556 96 Ip = padarray(I,[1 1],1,'both');
97
98 % Adjust input seed locations for zero-padded input.
0.11 7556 99 r = r(:)+1;
0.07 7556 100 c = c(:)+1;
101
102 % Remove seed locations that are already one from the list.
0.20 7556 103 if (~isempty(r))
104 % Conditional necessary to work around uint8 array empty
105 % matrix indexing bug in MATLAB 5.0. -sle
0.30 7556 106 killIdx = find(Ip((c-1)*(M+2) + r) ~= 0);
0.06 7556 107 r(killIdx) = [];
0.02 7556 108 c(killIdx) = [];
0.01 7556 109 end
110
0.11 7556 111 idxList = r + (c-1)*(M+2);
0.11 7556 112 idxList(Ip(idxList)) = [];
113
3.93 7556 114 J = bwfillc(Ip, idxList, style);
115
0.39 7556 116 J = J(2:M+1,2:N+1);
117
0.61 7556 118 BW2 = J | I;
119
0.11 7556 120 switch nargout
0.01 7556 121 case 0
122 % BWFILL(...)
123
124 if (newFig)
125 figure;
126 end
127 imshow(BW2,'XData',xdata,'YData',ydata);
128
0.04 7556 129 case 1
130 % BW2 = BWFILL(...)
131
0.12 7556 132 varargout{1} = BW2;
133
134 case 2
135 % [BW2,IDX] = BWFILL(...)
136
137 varargout{1} = BW2;
138 varargout{2} = find(J & ~I);
139
140 otherwise
141 % [X,Y,BW2,...] = BWFILL(...)
142
143 varargout{1} = xdata;
144 varargout{2} = ydata;
145 varargout{3} = BW2;
146
147 if (nargout >= 4)
148 % [X,Y,BW2,IDX,...] = BWFILL(...)
149 varargout{4} = find(J & ~I);
150 end
151
152 if (nargout >= 5)
153 % [X,Y,BW2,IDX,Xi,...] = BWFILL(...)
154 varargout{5} = xi;
155 end
156
157 if (nargout >= 6)
158 % [X,Y,BW2,IDX,Xi,Yi] = BWFILL(...)
159 varargout{6} = yi;
160 end
161
162 if (nargout >= 7)
163 warning(message('images:bwfill:tooManyOutputs'));
164 end
165 end

Other subfunctions in this file are not included in this listing.