This is a static copy of a profile reportHome
images/private/morphop>ParseInputs (14245 calls, 24.304 sec)
Generated 05-Nov-2014 07:52:43 using cpu time.
subfunction in file /usr1/opt/matlab/7.13/toolbox/images/images/private/morphop.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
229 | pre_pad = output_is_full || (~... | 14245 | 6.920 s | 28.5% |  |
194 | if (ndims(getnhood(se(k))) >... | 75653 | 4.346 s | 17.9% |  |
169 | [padopt,packopt,unpacked_M] = ... | 14245 | 3.054 s | 12.6% |  |
180 | se = getsequence(se); | 14245 | 1.863 s | 7.7% |  |
165 | se = strelcheck(se,func_name,'... | 14245 | 1.813 s | 7.5% |  |
All other lines | | | 6.309 s | 26.0% |  |
Totals | | | 24.304 s | 100% | |
Children (called functions)
Code Analyzer results
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 117 |
Non-code lines (comments, blank lines) | 46 |
Code lines (lines that can run) | 71 |
Code lines that did run | 44 |
Code lines that did not run | 27 |
Coverage (did run/can run) | 61.97 % |
Function listing
time calls line
158 function [A,se,pre_pad,pre_pack, ...
159 post_crop,post_unpack,op_type,input_is_packed, ...
160 unpacked_M,mex_method] = ParseInputs(A,se,op_type,func_name,varargin)
161
0.41 14245 162 iptchecknargin(2,5,nargin-2,func_name);
163
164 % Get the required inputs and check them for validity.
1.81 14245 165 se = strelcheck(se,func_name,'SE',2);
0.71 14245 166 A = CheckInputImage(A, func_name);
167
168 % Process optional arguments.
3.05 14245 169 [padopt,packopt,unpacked_M] = ProcessOptionalArgs(func_name, varargin{:});
0.13 14245 170 if strcmp(packopt,'ispacked')
171 CheckUnpackedM(unpacked_M, size(A,1));
172 end
173
174 %
175 % Figure out the appropriate image preprocessing steps, image
176 % postprocessing steps, and MEX-file method to invoke.
177 %
178 % First, find out the values of all the necessary predicates.
179 %
1.86 14245 180 se = getsequence(se);
0.08 14245 181 num_strels = length(se);
1.62 14245 182 strel_is_all_flat = all(isflat(se));
0.06 14245 183 input_numdims = ndims(A);
0.07 14245 184 strel_is_single = num_strels == 1;
0.10 14245 185 class_A = class(A);
0.11 14245 186 input_is_uint32 = strcmp(class_A,'uint32');
0.05 14245 187 input_is_packed = strcmp(packopt,'ispacked');
0.06 14245 188 input_is_logical = islogical(A);
0.03 14245 189 input_is_2d = ndims(A) == 2;
0.08 14245 190 output_is_full = strcmp(padopt,'full');
191
0.09 14245 192 strel_is_all_2d = true;
0.17 14245 193 for k = 1:length(se)
4.35 75653 194 if (ndims(getnhood(se(k))) > 2)
195 strel_is_all_2d = false;
196 break;
197 end
0.29 75653 198 end
199
200 %
201 % Check for error conditions related to packing
202 %
0.03 14245 203 if input_is_packed && strcmp(op_type, 'erode') && (unpacked_M < 1)
204 error(message('images:morphop:missingPackedM'))
205 end
0.02 14245 206 if input_is_packed && ~strel_is_all_2d
207 error(message('images:morphop:packedStrelNot2D'))
208 end
0.06 14245 209 if input_is_packed && ~input_is_uint32
210 error(message('images:morphop:invalidPackedInputType'))
211 end
0.04 14245 212 if input_is_packed && ~strel_is_all_flat
213 error(message('images:morphop:nonflatStrelPacked'))
214 end
0.03 14245 215 if input_is_packed && (input_numdims > 2)
216 error(message('images:morphop:packedImageNot2D'))
217 end
0.04 14245 218 if input_is_packed && output_is_full
219 error(message('images:morphop:packedFull'))
220 end
221
222 %
223 % Next, use predicate values to determine the necessary
224 % preprocessing and postprocessing steps.
225 %
226
227 % If the user has asked for full-size output, or if there are multiple
228 % and/or decomposed strels that are not rectangular, then pre-pad the input image.
6.92 14245 229 pre_pad = output_is_full || (~strel_is_single && ~NhoodShapesOrthogonal(se));
230
231 % If the input image is logical, then the strel must be flat.
0.06 14245 232 if input_is_logical && ~strel_is_all_flat
233 error(message('images:morphop:binaryWithNonflatStrel', func_name))
234 end
235
236 % If the input image is logical and not packed, and if there are multiple
237 % all-flat strels, the prepack the input image.
0.01 14245 238 pre_pack = ~strel_is_single & input_is_logical & input_is_2d & ...
239 strel_is_all_flat & strel_is_all_2d;
240
241 % If we had to pre-pad the input but the user didn't specify the 'full'
242 % option, then crop the image before returning it.
0.08 14245 243 post_crop = pre_pad & ~output_is_full;
244
245 % If this function pre-packed the image, unpack it before returning it.
0.06 14245 246 post_unpack = pre_pack;
247
248 %
249 % Finally, determine the appropriate MEX-file method to invoke.
250 %
0.07 14245 251 if pre_pack || strcmp(packopt,'ispacked')
0.01 202 252 mex_method = sprintf('%s_binary_packed',op_type);
253
0.02 14043 254 elseif input_is_logical
0.01 1721 255 if input_is_2d && strel_is_single && strel_is_all_2d
0.13 1721 256 if isequal(getnhood(se), ones(3))
257 mex_method = sprintf('%s_binary_ones33',op_type);
1721 258 else
0.07 1721 259 mex_method = sprintf('%s_binary_twod',op_type);
1721 260 end
261 else
262 mex_method = sprintf('%s_binary',op_type);
263 end
0.02 12322 264 elseif strel_is_all_flat
265
0.75 12322 266 if useIPP3x3(class_A,se,input_is_2d,strel_is_single,strel_is_all_2d)
267 mex_method = sprintf('%s_gray_ipp33',op_type);
0.05 12322 268 else
0.37 12322 269 mex_method = sprintf('%s_gray_flat',op_type);
0.05 12322 270 end
271
272 else
273 mex_method = sprintf('%s_gray_nonflat',op_type);
274 end
Other subfunctions in this file are not included in this listing.