time | Calls | line |
---|
| | 287 | function [results, unmatched] = parseInputs(data,map,filename,varargin)
|
| | 288 |
|
| | 289 | % Validate required arguments
|
< 0.001 | 10 | 290 | validateattributes(data,{'double','single','logical','uint8','uint16'},{'nonempty'});
|
< 0.001 | 10 | 291 | if isempty(map)
|
< 0.001 | 10 | 292 | validateattributes(map,{'double'},{});
|
| | 293 | else
|
| | 294 | validateattributes(map,{'double'},{'2d','ncols',3,'>=',0,'<=',1});
|
< 0.001 | 10 | 295 | end
|
< 0.001 | 10 | 296 | validateattributes(filename,{'char', 'string'},{'nonempty', 'scalartext'});
|
| | 297 |
|
< 0.001 | 10 | 298 | propStrings = {'interlacetype', 'imagemodtime', ...
|
| | 299 | 'transparency', 'bitdepth', 'significantbits', 'alpha', ...
|
| | 300 | 'background', 'gamma', 'xresolution', 'chromaticities', ...
|
| | 301 | 'yresolution', 'title', 'author', 'resolutionunit', ...
|
| | 302 | 'description', 'source', 'software', 'creationtime', ...
|
| | 303 | 'disclaimer', 'warning', 'copyright', 'comment' };
|
| | 304 |
|
| | 305 | % Process varargin into a form that we can use with the input parser.
|
< 0.001 | 10 | 306 | for k = 1:2:length(varargin)
|
< 0.001 | 50 | 307 | prop = lower(varargin{k});
|
< 0.001 | 50 | 308 | if (~ischar(prop))
|
| | 309 | error(message('MATLAB:imagesci:writepng:parameterNotString'));
|
< 0.001 | 50 | 310 | end
|
| | 311 |
|
< 0.001 | 50 | 312 | idx = find(strncmp(prop, propStrings, numel(prop)));
|
< 0.001 | 50 | 313 | if (length(idx) > 1)
|
| | 314 | error(message('MATLAB:imagesci:validate:ambiguousParameterName', prop));
|
< 0.001 | 50 | 315 | elseif isscalar(idx)
|
< 0.001 | 50 | 316 | varargin{k} = propStrings{idx};
|
< 0.001 | 50 | 317 | end
|
< 0.001 | 50 | 318 | end
|
| | 319 |
|
| | 320 | % Define the parser
|
0.001 | 10 | 321 | p = inputParser;
|
< 0.001 | 10 | 322 | p.KeepUnmatched = true;
|
| | 323 |
|
| | 324 | % Add PV pairs to the input parser
|
< 0.001 | 10 | 325 | p.addParameter('bitdepth',[], @(x)validateattributes(x,{'double'},{'scalar'}));
|
< 0.001 | 10 | 326 | p.addParameter('significantbits',[],@(x)validateattributes(x,{'double'},{'nonempty','>=',1}));
|
< 0.001 | 10 | 327 | p.addParameter('transparency',[], @(x)validateattributes(x,{'double'},{'>=',0,'<=',1}));
|
< 0.001 | 10 | 328 | p.addParameter('alpha',[], @(x)validateattributes(x,{'double','uint8','uint16'},{'size',[size(data,1) size(data,2)]}));
|
< 0.001 | 10 | 329 | p.addParameter('background',[], @(x)validateattributes(x,{'char','double','string'},{'row','nonempty'}));
|
< 0.001 | 10 | 330 | p.addParameter('gamma',[], @(x)validateattributes(x,{'double'},{'scalar','>=',0}));
|
< 0.001 | 10 | 331 | p.addParameter('chromaticities',[], @(x)validateattributes(x,{'double'},{'row','numel',8,'>=',0,'<=',1}));
|
< 0.001 | 10 | 332 | p.addParameter('xresolution',[], @(x)validateattributes(x,{'double'},{'scalar'}));
|
< 0.001 | 10 | 333 | p.addParameter('yresolution',[], @(x)validateattributes(x,{'double'},{'scalar'}));
|
< 0.001 | 10 | 334 | p.addParameter('title',[], @(x)validateattributes(x,{'char', 'string'},{'nonempty', 'scalartext'}));
|
< 0.001 | 10 | 335 | p.addParameter('author',[], @(x)validateattributes(x,{'char', 'string'},{'nonempty', 'scalartext'}));
|
< 0.001 | 10 | 336 | p.addParameter('description',[], @(x)validateattributes(x,{'char', 'string'},{'nonempty', 'scalartext'}));
|
< 0.001 | 10 | 337 | p.addParameter('copyright',[], @(x)validateattributes(x,{'char', 'string'},{'nonempty', 'scalartext'}));
|
< 0.001 | 10 | 338 | p.addParameter('software',[], @(x)validateattributes(x,{'char', 'string'},{'nonempty', 'scalartext'}));
|
< 0.001 | 10 | 339 | p.addParameter('disclaimer',[], @(x)validateattributes(x,{'char', 'string'},{'nonempty', 'scalartext'}));
|
< 0.001 | 10 | 340 | p.addParameter('warning',[], @(x)validateattributes(x,{'char', 'string'},{'nonempty', 'scalartext'}));
|
< 0.001 | 10 | 341 | p.addParameter('source',[], @(x)validateattributes(x,{'char', 'string'},{'nonempty', 'scalartext'}));
|
< 0.001 | 10 | 342 | p.addParameter('comment',[], @(x)validateattributes(x,{'char', 'string'},{'nonempty', 'scalartext'}));
|
< 0.001 | 10 | 343 | p.addParameter('creationtime',[], @(x)validateattributes(x,{'char','double', 'string'},{'nonempty'}));
|
< 0.001 | 10 | 344 | p.addParameter('imagemodtime',[], @(x)validateattributes(x,{'char','double', 'string'},{'nonempty'}));
|
< 0.001 | 10 | 345 | p.addParameter('interlacetype','none', @(x) validateattributes(x,{'char', 'string'},{'nonempty', 'scalartext'}));
|
< 0.001 | 10 | 346 | p.addParameter('resolutionunit',[], @(x)validateattributes(x,{'char', 'string'},{'nonempty', 'scalartext'}));
|
| | 347 |
|
| | 348 | % Parse remaining arguments and return results and unmatched
|
0.005 | 10 | 349 | p.parse(varargin{:});
|
< 0.001 | 10 | 350 | results = p.Results;
|
0.001 | 10 | 351 | unmatched = p.Unmatched;
|
Other subfunctions in this file are not included in this listing.