cannot resize images in a datastore
8 views (last 30 days)
Show older comments
Mahmoud Dinar
on 24 Feb 2022
Commented: Mahmoud Dinar
on 24 Feb 2022
I was going through the Deep Learning with MATLAB course and working on the first project. I tried to resize the images to feed them into googlenet. The original datastore had 1000+ images of size [200 200 3]. I tried:
trainds = augmentedImageDatastore([224 224],original_trainds);
but when I read the first image, the size had not changed. The baffling part was that when I looked at the provided solution, it was exactly what I had thought.
trainDs = augmentedImageDatastore([224 224],trainImgs);
I don't know which step went wrong. Thanks for your help.
0 Comments
Accepted Answer
Image Analyst
on 24 Feb 2022
I think the image scaling happens "on the fly" when doing training. I'm pretty sure it does not save the scaled images. And you need to specify the amount to scale. Here's a snippet from my code which basically comes from the Mathworks example for SegNet
%------------------------------------------------------------------------------------------------------------------------------------------------
% Create Augmenter which applies random reflection/translation/scale
augmenter = imageDataAugmenter('RandXReflection',true,...
'RandXTranslation',[-10 10],'RandYTranslation',[-10 10],'RandXScale',[0.8 1.2]);
% create the datastore for images,labels and augmenter together
pximds = pixelLabelImageDatastore(imds,pxds,'DataAugmentation',augmenter);
%Train Front - 50 epochs and 10 Augmentations per mask
options = trainingOptions('sgdm','InitialLearnRate',1e-3, ...
'MaxEpochs',1000,'VerboseFrequency',1,'MiniBatchSize',4,'Shuffle','every-epoch','Plots','training-progress','CheckpointPath',checkpointPath );
More Answers (1)
yanqi liu
on 24 Feb 2022
yes,sir,may be augmentedImageDatastore process as function,such as
which cameraman.tif
imdsTrain = imageDatastore(fullfile(matlabroot,'toolbox/images/imdata'), ...
'IncludeSubfolders',true,'LabelSource','foldernames');
augimdsTrain = augmentedImageDatastore([224 224],imdsTrain,'ColorPreprocessing','gray2rgb');
img1 = readimage(imdsTrain,1);
size(img1)
db = read(augimdsTrain);
img2 = db.input{1};
size(img2)
0 Comments
See Also
Categories
Find more on Image Data Workflows 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!