Explicitly split the imagedataset into training and testing set

3 views (last 30 days)
I having dataset contains 1800 images in 10 subfolders. Each subfolder contain 180images.
I want to split my dataset into Train and Test. I want 10th,20th, 30th, ...., 180th images in each subfolder as test set. Remaining as training set.
After that i have to split my Train set into 3 part (XTrain1, XTrain2, XTrain3).
This is the code i have used:
imagefolder = 'C:\Users\manjurama\Desktop\study\PG\PROJECT\Finger vein database multiple copy\database_10';
imds = imageDatastore(imagefolder,'IncludeSubfolders',true,'LabelSource','foldernames');
numTrainingFiles = 162;
[Train, Test] = splitEachLabel(imds,numTrainingFiles);
[XTrain11, XTrain21, XTrain31] = splitEachLabel(imds, 0.333, 0.333, 0.333);
XTrain1 = augmentedImageDatastore([227 227],XTrain11);
XTrain2 = augmentedImageDatastore([227 227],XTrain21);
XTrain3 = augmentedImageDatastore([227 227],XTrain31);
But i wont work
Also i need to find the class information.
I used following code. But it wont work
classes = XTrain1.Labels; % retrieve the class information
numClasses = numel(classes);
Kindly help to do the above task. Thanks in advance.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!