Reputation: 48916
I have the following imwrite
statement:
imwrite(img, strcat(thisdir,'_',num2str(j),'_LABEL_',categoryClassifier.Labels(labelIdx),'.jpg'));
where categoryClassifier.Labels(labelIdx)
returns a string
, and thisdir
is also a string
returning the directory name. But, I get the following error:
Error using imwrite>parse_inputs (line 510)
A filename must be supplied.
Error in imwrite (line 418)
[data, map, filename, format, paramPairs] = parse_inputs(varargin{:});
Isn't the part from strcat
considered the filename?
Thanks.
Upvotes: 0
Views: 909
Reputation: 1597
This is kinda a shot in the dark, but I suspect that you want categoryClassifier.Labels{labelIdx}
rather than categoryClassifier.Labels(labelIdx)
(the difference is the curly braces).
Assuming that categoryClassifier.Labels
is a cell array of strings, the curly braces give you the contents of that cell (which is what you want), whereas the parentheses give you a 1x1 cell array (which looks a lot like a string in MATLAB's command window). Note also that strcat
is perfectly happy to process a cell array of strings, so it doesn't complain, but imwrite
freaks out because none of its arguments are a string.
Upvotes: 1