saving images into ImageDatastore

9 views (last 30 days)
Robert Eggleston
Robert Eggleston on 13 Sep 2019
Commented: Walter Roberson on 13 Sep 2019
Hello all, I am working with some code where I am tasked with recreating a new imageDatastore in order to retrain a neural network. The entire code is in a for loop and I am having trouble saving a reproduced image to a datastore without it getting overwritten every iteration. I need to save Irec into a datastore so that I can then move to retraning the neural network however I am at a bit of a loss regarding how to do this.
% set negative values to zero and scale reconstructed image
% to integers in range [0,255];
Irec = max(0,Irec);
Irecmax = max(max(Irec));
Irec = 255*Irec/Irecmax;
%Irec = floor(Irec+.5-eps);
subplot(222)
imshow(Irec,[0 255]);
title(['Reconstructed with ' num2str(pview) ' views in [0, ' num2str(thetamax) ']']);
dr = classify(netTransfer,Irec);
xlabel(['Classified as: ' char(dr)]);
subplot(223);
plotrow=14;
plot(Irec(plotrow,:));
title(['Reconstruction: Plot of row ' num2str(plotrow)])
  1 Comment
Walter Roberson
Walter Roberson on 13 Sep 2019
When you go through the image data store, if you use readImage instead of read, then you can be tracking which image you are reading. Use the image number to index into the Files property of the datastore in order to find the source for the current file. fileparts() to extract the directory and base name and extension, and create a modified version of the name, put the parts back together to get an output file name. Now save content to that output file.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!