Why does "splitEachLabel" function error when using an "augmentedImageDatastore" as input?
14 views (last 30 days)
Show older comments
MathWorks Support Team
on 21 Sep 2023
Answered: MathWorks Support Team
on 26 Sep 2023
I am using the "splitEachlabel" function to split my image data using the following code:
% create imageDatastore
imds = imageDatastore(fullfile(matlabroot, 'toolbox', 'matlab', {'demos','imagesci'}),...
'LabelSource', 'foldernames', 'FileExtensions', {'.jpg', '.png', '.tif'});
% create augmentedImageDatastore
auimds = augmentedImageDatastore([256 256 3],imds,'ColorPreprocessing','rgb2gray');
% splitEach label for imageDatastore
[imds60,imds40] = splitEachLabel(imds ,0.6);
% splitEach label for augmentedImageDatastore
[auimds60,auimds40] = splitEachLabel(auimds ,0.6);
This works for "imageDatastore" objects but when using "augmentedImageDatastore" objects, I receive the following error:
Incorrect number or types of inputs or outputs for function splitEachLabel.
How can I use "splitEachLabel" function for "augmentedImageDatastore"?
Accepted Answer
MathWorks Support Team
on 21 Sep 2023
This is expected behaviour, the "augmentedImageDatastore" object does not have a object function named "splitEachLabel".
Please ensure that you split the data first, and then create the "augmentedImageDatastore" object. For example:
% create imageDatastoreimds = imageDatastore(fullfile(matlabroot, 'toolbox', 'matlab', {'demos','imagesci'}),...
'LabelSource', 'foldernames', 'FileExtensions', {'.jpg', '.png', '.tif'});
% splitEach label for imageDatastore
[imds60,imds40] = splitEachLabel(imds ,0.6);
% create augmentedImageDatastores
auimds60 = augmentedImageDatastore([256 256 3],imds60,'ColorPreprocessing','rgb2gray');
auimds40 = augmentedImageDatastore([256 256 3],imds40,'ColorPreprocessing','rgb2gray');
0 Comments
More Answers (0)
See Also
Categories
Find more on Datastore in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!