augmentedImageDatastore center crop does not return datastore with labels
27 views (last 30 days)
I have an image datastore which includes images and labels. Before feeding to the network, I want to crop the images at the center. However, I noticed that imdsTrain_crop does not have label information as imdsTrain does.
imdsTrain_crop = augmentedImageDatastore([28,28],imdsTrain,'OutputSizeMode','centercrop');
Notice below how the ImageDatastore object has Labels but the augmentedImageDatastore does not. Is there any way to work around this?
I know that augmentedImageDatastore.Files will have information of the filepath for each image, which I can read and then label accoordingly, but this seems troublesome when there could be a simpler solution.
Sai Bhargav Avula on 26 May 2020
Edited: Sai Bhargav Avula on 26 May 2020
One way to address this is to use pixelLabelDatastore for loading the labels
pixelLabelImageDatastore to create the datastore for training.
imdsTrain = imageDataStore(imageDir);
pxdsTrain = pixelLabelDatastore(labelDir,ClassNames,labelIds);
trainingData = pixelLabelImageDatastore(imds,pxds,'OutputSizeMode','centercrop','OutputSize',[28,28]);
or transform function over the datastores.
Hope this helps!